Overview
When working with TD Web Service Methods calls it is possible to pull data through a GET and store the return data body in the workflow for use by a subsequent TD Web Service Method. Once you have that data, it is possible to pull specific data points from the returned data set.
Preparing the Data on First API Method
This is assuming you have a created GET API Method to use in your workflow and you have created Web Service Auth Accounts and Web Service Providers.
For details on initial setup for Web API look at these articles: API Content
If you need examples of GET method building review this example: Using Web Services to Copy a Ticket
- Navigate to TDAdmin>Applications>Ticketing App>Workflows
- Create your new workflow where you will use these API calls
- In your workflow add a step
- Select Web Service as the Type
- Select the GET Method you have already created
- In the Store Results section enter a value for the Response Body; such as "Response"
- This name will be needed when building the method that utilizes the data
Create Second API Method
- Navigate to TDAdmin>Applications>Ticketing App>Workflow Web Services>Web Service Methods
- Create a new method that will utilize your data from the first GET
- For details on API Methods click on the blue "TD API Docs" help button in the upper right of the new method screen to get URL strings for your method type
For this example we will use a POST method that will comment the isolated data points onto the ticket as a proof of concept. Choose the type of API Call that makes sense for your use case.
- Name your Method
- Choose your Web Service Provider
- choose POST
- Enter the URL string for commenting on a ticket feed: https://YOURDOMAIN/TDWebApi/api/{{appID}}/tickets/{{id}}/feed
- Headers
- Key: Content-Type
- Value: application/json
- Select the Parameters Tab
- Add these parameters:
- AppID – integer – From Ticket – Application ID (if you already know the ticketing appID, enter it above in the URL, and disregard adding it to Parameters.)
- id - Integer - From Ticket - ID
This is the point where you can get specific data
- Add another parameter with these configs:
- Name = Select a name to use later in the Body to ID the data (for this example use Data1)
- Data Type = String
- Source = From Workflow
- Source Property = RESPONSEBODYNAME.[ID#].Value
- RESPONSEBODYNAME should be replaced with the name of the value entered in the Response Body from the workflow step creation on the first API Method
- ID# refers to the object in the data list - Meaning if you pull a data list that includes more than one object you must select a specific object to pull from. The default would be [0].
- Value = the data type you are trying to pull.
- EXAMPLE - Your GET pulled data of all contacts on a ticket. You saved the Response Body with the value of "Contacts". There are 3 contacts on this ticket. You want to specifically use the second contacts "PrimaryEmail" value in the body of the API Method. You would enter a source property of: Contacts.[1].PrimaryEmail
- Navigate to the Body
- Apply the coding to add a comment on the ticket that lists the primary email for the selected contact:
- {"Comments":"{{Data1}}"}
- In this case the {{Data1}} will refer to the data you outlined in the parameter. Remember to use whatever name inside the curly brackets that you selected for that parameter
- Save the Method
- Add a step in your original workflow and insert your second API Method