Integrations and APIs for Service

Get Involved. Join the Conversation.

Topic

    Michel Jilderda
    Getting all Incident Threads in one call via REST?Answered
    Topic posted February 7, 2017 by Michel JilderdaBlue Ribbon: 750+ Points, tagged REST 
    659 Views, 8 Comments
    Title:
    Getting all Incident Threads in one call via REST?
    Content:

    Hi all, 
    we are building a separate webpage where we want to show incident details on an external webpage. While we have built this before using SOAP, we are using the REST API now. One of the things we run into is this: 
    With a SOAP request, it was possible to get all incident threads in 1 soap call. 

    With the REST API there does not seem to be a way to do this in 1 call. So what we need to do to show the threads is a lot of calls to the API, which causes delay in loading the page. 

    These are the calls we do now. We have the incident reference number to start with, so this is the sequence of calls to the REST API. 

    1. Get incident ID for reference number
      https://{{siteURL}}/services/rest/connect/v1.3/incidents/?q=lookupName='{{exampleIncidentRefno}}'
    2. Get Incident details
      https://{{siteURL}}/services/rest/connect/v1.3/incidents/{{exampleIncidentID}}
    3. Get Threads for Incidents
      https://teamcx-uk.custhelp.com/services/rest/connect/v1.3/incidents/{{exampleIncidentID}}/{{exampleThreadID}}
    4. Now we can loop through all the threads.
    5. Now, to populate the threads with the correct account names, we also need to get all the account names for the threads again.

    Again, for SOAP this was a lot easier. Are we missing something? Is there a way to pull this from REST as well without doing 10+calls to get all incident details? 

    Version:
    AUG2016

    Best Comment

    Scott Harwell

    You could use ROQL and get the incident and thread data in a single call:

    SELECT *, Threads.* FROM Incident WHERE ReferenceNumber = '170206-000000'
    

    Or, threads only:

    SELECT Threads.* FROM Incident WHERE ReferenceNumber = '170206-000000'
    

    Comment

     

    • Scott Harwell

      You could use ROQL and get the incident and thread data in a single call:

      SELECT *, Threads.* FROM Incident WHERE ReferenceNumber = '170206-000000'
      

      Or, threads only:

      SELECT Threads.* FROM Incident WHERE ReferenceNumber = '170206-000000'
      
    • Michel Jilderda

      It works like a charm Scott, thanks very much for your help!

      We tried some things yesterday, but were not able to get it working. 

      I did have to change 'Incident' to 'Incidents', so the complete REST query is:

      https://{{siteURL}}/services/rest/connect/v1.3/queryResults/?query=SELECT *, Threads.* FROM Incidents WHERE ReferenceNumber = '{{exampleIncidentRefno}}'

    • Danette Beal

      So glad Scott could get you what you needed Michel.

      Thank you for updating us and letting us know you resolved your issue!

      Regards,

      Danette, Community Manager

    • Ryan

      <obligatory /grumble RE: OSvC REST syntax>

    • Michel Jilderda

      @ Ryan's grumble: 

      I know, I will never understand why Oracle chose to use a different syntax for ROQL via REST, compared to via SOAP.  Was it an accident, or did they do it on purpose? We will never know.

    • Scott Harwell

      While using plurals is a break from the singular noun convention of legacy OSvC APIs, this was almost certainly an intentional design choice to follow general REST API conventions of using plural nouns for object paths as opposed to legacy OSvC conventions.

    • Neil

      I know this is an old thread but it's also worth noting that at least in the latest versions you can specify which subobjects to populate. e.g.:

      /services/rest/connect/latest/incidents/12345?expand=threads,fileAttachments - This returns the incident with all the threads and attachments.

    • Maheep Kaur

      Hi Mr Mann,

      I tried your way, but through this also I am getting the Thread IDs but not the content ahead.

       "href": "https://***/services/rest/connect/latest/incidents/148135474/threads/283343044"