How To Make Orchestrator API Requests Using HTTP Request Activities?

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:

  1. Orchestrator HTTP Request Activity
  2. 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

  1. Find the Orchestrator HTTP Request activity in Activities panel

![](upload://8Ag9yydrTYeWXlXBNKnhI9y1OqY.html)

  1. Make sure that Robot is connected to Orchestrator in Studio

![](upload://7yzZCrDzI9AtB6hnGaNd4pVUVLH.html)

  1. The activity Properties panel should look like this

Method: GET

RelativeEndpoint: "/odata/ProcessSchedules"

Folder Path (specify the full folder path in Orchestrator): "Shared/UnattendedFolder"

  1. Create a variable for JSONResponse (it will have a String type): JSONResponse

![](upload://giqOPjcigNmr97Wi5QChoWhPLzo.html)

  1. Use the Deserialize JSON activity

![](upload://vFxw3npCh7fWdeXmf6txO84AGVG.html)

  1. In JsonString provide the already created variable JSONResponse, and in JsonObject create a new variable JsonObject (TypeArgument: Newtonsoft.Json.Linq.JObject)

![](upload://3PxS5Wo1oEoT5moYRIl9RwMyPe1.html)

  1. 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:

  1. Find the HTTP Request activity in Activities panel

![](upload://hrpyns1tNACc1OE9GyYqUManyHX.html)

  1. 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)

  1. 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)

  1. 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)

  1. Add a small delay to make sure the robot prepared already the AccessTokenString

![](upload://xsUkGYhQYmwKxOFGT6Cstin2SVA.html)

![](upload://2Dh7LaBLkxUQ6nMmfwxNfxpgTtM.html)

  1. 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

  1. Use the Deserialize JSON activity

![](upload://vFxw3npCh7fWdeXmf6txO84AGVG.html)

JsonString: GetResults

JsonObject (create a new variable): GetResultsFromDeserialize

![](upload://2vL80XOjDr44reJdbpT2VmZnV59.html)

  1. With For Each activity, extract the needed data
  • TypeArgument: Newtonsoft.Json.Linq.JObject
  • Values: GetResultsFromDeserialize.GetValue("value")

![](upload://p9Ze2uy4RTIeJ2u1CeNC4nZB8o7.html)

  1. 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:

image.png