How to add a Queue item in StudioX using HTTP Request activities?
Note: In this tutorial, internally tested example of getting the client_credentials access_token and using it afterward in the request of adding a Queue item using the /odata/Queues/UiPathODataSvc.AddQueueItem endpoint, is presented. This example can be readapted for any RestApi request endpoints for StudioX profile.
For StudioX follow below approach:
- From Manage Packages find and install the UiPath.WebAPI.Activities[1.7.0]
- Add an HTTP Request activity from the Activities panel
- Configure the Properties panel for the HTTP Request activity as below:
AcceptFormat: ANY
Endpoint: https://cloud.uipath.com/identity_/connect/token
Method: POST
Body: leave empty
BodyFormat: application/x-www-form-urlencoded
Cookies: leave empty
Headers: leave empty
Result: create a variable for example named Results
Parameters:
Example:
grant_type: "client_credentials"
client_id: "fee699da-3582-45bb-8777-365ad3480aaa"
scope: "OR.Folders OR.Robots OR.Queues"
client_secret: "6UzLHYr%^wbO9aaa"
- If adding a Write Line activity and selecting the Results variable, in the end, run the process, the needed results will be obtained exactly as in Postman Tool:
- In order to get the needed access token and reuse it in another activity, follow the next steps:
- Use a Write Text File activity as bellow:
Text: (Split((Split(Saved.Values(Of System.String)("Results"),",")(0).ToString),":")(1).ToString).Substring(1,(Split((Split(Saved.Values(Of System.String)("Results"),",")(0).ToString),":")(1).ToString).Length-2)
Write to filename: TokenFromCloud.txt
- Use a Read Text File activity as bellow:
Filename: TokenFromCloud.txt
In the Properties panel, create a new variable AccesToken:
- For testing purposes, use a Write Line activity and select the saved variable AccessToken:
Text: "Access token is: " + Saved.Values(Of System.String)("AccessToken")
Results:
- In order to add a queue item, add the JSON data in a.TXT file in your project and use a Read Text File activity:
JSON data to add a queue item:
{
"itemData": {
"Priority": "Normal",
"DeferDate": "2022-03-21T13:42:27.654Z",
"DueDate": "2022-03-25T13:42:27.654Z",
"Name": "Queue_1",
"Reference": "marian_test_q_item_3",
"SpecificContent": {
"Email": "marian.test@uipath.com",
"Name": "Marian Test"
}
}
}
In the Read Text File in the Output to parameter create a new variable named AddQueueItemValue
- For testing purposes, add a Write Line activity to display the content of the variable AddQueueItemValue
Results:
- Add a new HTTP Request activity and configure it as below,
AcceptFormat: ANY
Endpoint: "https://cloud.uipath.com/ACCOUNT_NAME/TENANT_NAME/odata/Queues/UiPathODataSvc.AddQueueItem"
Method: POST
Body: AddQueueItemValue
BodyFormat: application/json
Cookies: leave empty
Headers:
X-UIPATH-OrganizationUnitId: "FOLDER_ID"
Content-Type: "application/json"
Authorization: "Bearer " + Saved.Values(Of System.String)("AccessToken")
Parameters: leave empty
Result: Create a variable for example named ResultOfAddedQueueItem
- For testing purposes, add a Write Line activity to display the content of the variable AddQueueItemValue
Results: