How to make Orchestrator API Requests using HTTP Request activities?
Note: In the below example, usage of the "/odata/ProcessSchedules" REST API endpoint is explained. Readapt the steps based on current needs.
In order to make Orchestrator API Requests using HTTP Request activities, two options are present:
- Orchestrator HTTP Request Activity
- HTTP Request Activity
1. Using Orchestrator HTTP Request Activity
- To use this approach, Robot should be connected to Orchestrator and it does not require to authenticate the Orchestrator using Authenticate API.
- Pass the relative endpoint in the "RelativeEndpoint" like "/odata/ProcessSchedules"
Refer the Orchestrator HTTP Request .
Example for the Orchestrator HTTP Request Activity
- Find the Orchestrator HTTP Request activity in Activities panel
![](upload://8Ag9yydrTYeWXlXBNKnhI9y1OqY.html)
- Make sure that Robot is connected to Orchestrator in Studio
![](upload://7yzZCrDzI9AtB6hnGaNd4pVUVLH.html)
- The activity Properties panel should look like this
Method: GET
RelativeEndpoint: "/odata/ProcessSchedules"
Folder Path (specify the full folder path in Orchestrator): "Shared/UnattendedFolder"
- Create a variable for JSONResponse (it will have a String type): JSONResponse
![](upload://giqOPjcigNmr97Wi5QChoWhPLzo.html)
- Use the Deserialize JSON activity
![](upload://vFxw3npCh7fWdeXmf6txO84AGVG.html)
- In JsonString provide the already created variable JSONResponse, and in JsonObject create a new variable JsonObject (TypeArgument: Newtonsoft.Json.Linq.JObject)
![](upload://3PxS5Wo1oEoT5moYRIl9RwMyPe1.html)
- In order to retrieve the needed data, use the For Each activity:
In: JsonObject.GetValue("value")
Message: "Id: "+ Convert.ToString(item.GetValue("Id")) + ", Name: "+Convert.ToString(item.GetValue("Name")) + " ->StartProcessCronDetails: " +Convert.ToString(item.GetValue("StartProcessCronDetails"))
![](upload://oIEGvF65fNs4TL3lfi0i3kE1y0f.html)
Results:![](upload://b9iPokVJURe7Mspz3IJHAmjZ9Ht.html)
2. Using HTTP Request Activity
Robot connectivity with Orchestrator is not required and it is required to authenticate the Orchestrator by making a HTTP POST request to the below API endpoint:
- [Orchestrator Url]/api/Account/Authenticate
- Its response will return a token, which is stored in the "result" key of the JSON response
- The above parameters need to be passed in the header, to make HTTP Post Request to Start Jobs API.
Example for the Orchestrator HTTP Request Activity:
- Find the HTTP Request activity in Activities panel
![](upload://hrpyns1tNACc1OE9GyYqUManyHX.html)
- In the Properties panel you should have these values in place:
Timeout (milliseconds): 10000
Endpoint: "https://ORCHESTRATOR_URL/api/Account/Authenticate"
Method: POST
Body:
@"{
" + "\n" +
@"""tenancyName"":""TENANT_NAME"",
" + "\n" +
@"""usernameOrEmailAddress"":""USERNAME"",
" + "\n" +
@"""password"":""PASSWORD""
" + "\n" +
@"}";
BodyFormat: application/json
Result (create a new variable): ResponseResults
![](upload://j1c4ob1cQ5XXhquD6K9YYQ8fTrj.html)
- Use the Deserialize JSON activity
![](upload://vFxw3npCh7fWdeXmf6txO84AGVG.html)
In JsonString use ResponseResults variable
In JsonObject create a new variable AccessToken (it will have Type: Newtonsoft.Json.Linq.JObject)
![](upload://o2wummYIRfzauZUGORqhsCfpzQI.html)
- Use the Assign activity to transform the Access token value to the expected String value in the Authorization header request.
Create a new variable AccessTokenString that is having this value "Bearer " + Convert.ToString(AccessToken.GetValue("result"))
![](upload://i5VfMWX7sX0FOuSq1PoPUGQeGLs.html)
- Add a small delay to make sure the robot prepared already the AccessTokenString
![](upload://xsUkGYhQYmwKxOFGT6Cstin2SVA.html)
![](upload://2Dh7LaBLkxUQ6nMmfwxNfxpgTtM.html)
- Use a new HTTP Request activity that is having these values configured:
AccepptFormat: ANY
Endpoint: "https://laptop-8fj7qmnd/odata/ProcessSchedules"
Method: GET
BodyFormat: application/json
In Options -> Headers add two values:
- Authorization in String AccessTokenString
- X-UIPATH-OrganizationUnitId In String "7" (this is the folder id where the processes are located)
![](upload://4YDclWvGckOpG0RbZkRyLlKHDOD.html)
In Output -> Result create a new variable GetResults
- Use the Deserialize JSON activity
![](upload://vFxw3npCh7fWdeXmf6txO84AGVG.html)
JsonString: GetResults
JsonObject (create a new variable): GetResultsFromDeserialize
![](upload://2vL80XOjDr44reJdbpT2VmZnV59.html)
- With For Each activity, extract the needed data
- TypeArgument: Newtonsoft.Json.Linq.JObject
- Values: GetResultsFromDeserialize.GetValue("value")
![](upload://p9Ze2uy4RTIeJ2u1CeNC4nZB8o7.html)
- Log Message activity:
LogLevel: LogLevel.Info
Message: "Id: "+ Convert.ToString(item.GetValue("Id")) + ", Name: "+Convert.ToString(item.GetValue("Name")) + " ->StartProcessCronDetails: " +Convert.ToString(item.GetValue("StartProcessCronDetails"))
Results:
![](upload://lNyQRVNZPJckCD5Kc02HdaiELQ6.html)
====
In the case when it is needed to check the @odata.count value of the JSON response, check by adding an extra Log Message activity in workflow with this Message:
"@odata.count: " + Convert.ToString(JsonObject.GetValue("@odata.count"))
Results: