How To Add A Queue Item In StudioX Using HTTP Request Activities?

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:

  1. From Manage Packages find and install the UiPath.WebAPI.Activities[1.7.0]

1.png

  1. Add an HTTP Request activity from the Activities panel

2.png

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

3.png

4.png

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

5.png

6.png

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

7.png

  1. Use a Read Text File activity as bellow:

Filename: TokenFromCloud.txt

8.png

In the Properties panel, create a new variable AccesToken:

9.png

  1. For testing purposes, use a Write Line activity and select the saved variable AccessToken:

Text: "Access token is: " + Saved.Values(Of System.String)("AccessToken")

10.png

Results:

11.png

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

}

}

}

33.png

In the Read Text File in the Output to parameter create a new variable named AddQueueItemValue

12.png

  1. For testing purposes, add a Write Line activity to display the content of the variable AddQueueItemValue

13.png

Results:

55.png

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

14.png

Parameters: leave empty

Result: Create a variable for example named ResultOfAddedQueueItem

15.png

  1. For testing purposes, add a Write Line activity to display the content of the variable AddQueueItemValue

16.png

Results:

44.png