Skip to content

Instantly share code, notes, and snippets.

@cmaggiulli
Last active June 29, 2018 03:19
Show Gist options
  • Save cmaggiulli/9e3011a4660cdf4c13968f1e360ea574 to your computer and use it in GitHub Desktop.
Save cmaggiulli/9e3011a4660cdf4c13968f1e360ea574 to your computer and use it in GitHub Desktop.
Shell script to retrieve FileName's, FileID's, and the IncidentID from a ReferenceNumber in Oracle Service Cloud (RightNow) using the RESTful Connect API v1.4
#!/bin/sh
# Author: Chris Maggiulli
# Email: [email protected]
# Platform: Oracle Service Cloud (RightNow) Connect REST API v1.4
# Description: Sends ROQL to a RESTful service to retrieve FileNames, FileIDs, and the IncidentID from a ReferenceNumber
# Usage: ./incident-file-information.sh {Usernmae} {Password} {BaseURL (without protocol schema)} {RefeenceNumber}
# Example: ./incident-file-information.sh CMaggu0 Lifer12 yoururl.custhelp.com/ 188011-0919
ROQL="SELECT
Incidents.id AS IncidentID,
Incidents.FileAttachments.FileAttachmentList.id AS FileID,
Incidents.FileAttachments.FileAttachmentList.fileName As FileName
FROM
Incidents
WHERE
Incidents.FileAttachments.FileAttachmentList.id IS NOT NULL
AND
referenceNumber = '$4'"
curl -s \
-H "Accept: application/json" \
-H "OSvC-CREST-Application-Context: ABCD" \
-u "$1:$2" \
-G "https://$3/services/rest/connect/v1.4/queryResults" \
--data-urlencode "query=$ROQL" | json_pp -f json -json_opt pretty
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment