Adding queue items using Oauth

Hi forum,

I’ve recently upgraded to Orchestrator 21.10.2 onPrem and I’m now trying the API with OAuth and an external confidential app.
Since I only try it, I use a command shell and curl commands (like the examples from Swagger UI).

The external app has OR.Machines and OR.Queue as scope.
I can successfully obtain a token and then create a new Queue using the examples from Swagger UI + the token obtained earlier:

curl -X POST "https://<MYORCH>/odata/QueueDefinitions" -H "Authorization: Bearer <MYTOKEN>"  -H  "accept: application/json" -H  "Content-Type: application/json;odata.metadata=minimal;odata.streaming=true" -d "{  \"Name\": \"TESTCURL\"}"

But when I try to add an empty item to the queue:

curl -X POST "https://<MYORCH>/odata/Queues/UiPathODataSvc.AddQueueItem" -H "Authorization: Bearer access_token <MYTOKEN>" -H "accept: application/json" -H  "Content-Type: application/json;odata.metadata=minimal;odata.streaming=true" -d "{  \"itemData\": {    \"Name\": \"TESTCURL\"  }}"

it fails, saying I need to sign in.

{“message”:“You are not authenticated!”,“errorCode”:0,“result”:null,“targetUrl”:null,“success”:false,“error”:{“code”:0,“message”:“You are not authenticated!”,“details”:“You should be authenticated (sign in) in order to perform this operation.”,“validationErrors”:null},“unAuthorizedRequest”:true,“__abp”:true}

I copied the commands from the Swagger UI where I actually can add an item to that queue.
At first I thought that I presented the token in a wrong way but since it allows me th create a queue, it can’t be that wrong.

Any ideas what I’m doing wrong?

Thanks and kind regards
Alexander

If your samples are representative of what you have attempted then your 2nd example has an incorrect Authorization header.

-H "Authorization: Bearer <MYTOKEN>"

vs

-H "Authorization: Bearer access_token <MYTOKEN>"

2 Likes

Wow. Thanks a lot!
I don’t understand how I could have missed that…

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.