Http 415 unsupported media type when adding queue item

Hi guys,

I trigger an automation by adding a queue item when a certain process on a server ends successfully. The server executes a powershell script which then authenticates and adds the queue items via the Orchestrator API

This worked fine until I upgraded to Orchestrator 20.10.3 on prem and and now the script fails with the Orchestrator reporting :

“Unsupported Media Type”,“status”:415

According to the documentation this authentication method is stil valid - have you got an idea what might have changed?

This is the authentication bit:

#Step 1: define variables

$tenantName = 'xx'#TenantName
$RPAuser ='xx'#RPAuser
$RPApassword = 'xx'#RPApassword
$RPAAuthUri = 'https://<ORCH_LINK>/api/account/authenticate' #URI to obtain Bearer Token
$RPADataUri = 'https://<ORCH_LINK>/odata/Queues/UiPathODataSvc.AddQueueItem' #URI to send new queue item to


#Step 2: Get an authentication token from Orchestrator
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
$postBody = @{tenancyName=$tenantName;usernameOrEmailAddress=$RPAuser;password=$RPApassword}
$headers = @{ContentType='application/json'}


$response = Invoke-WebRequest -Uri $RPAAuthUri -UseBasicParsing -Method POST -Body $postBody -Headers $headers | ConvertFrom-Json;
$token = ('Bearer ' + $response.result );

Thanks!
Alex

Hello @alexander.heilig!

It seems that you have trouble getting an answer to your question in the first 24 hours.
Let us give you a few hints and helpful links.

First, make sure you browsed through our Forum FAQ Beginner’s Guide. It will teach you what should be included in your topic.

You can check out some of our resources directly, see below:

  1. Always search first. It is the best way to quickly find your answer. Check out the image icon for that.
    Clicking the options button will let you set more specific topic search filters, i.e. only the ones with a solution.

  2. Topic that contains most common solutions with example project files can be found here.

  3. Read our official documentation where you can find a lot of information and instructions about each of our products:

  4. Watch the videos on our official YouTube channel for more visual tutorials.

  5. Meet us and our users on our Community Slack and ask your question there.

Hopefully this will let you easily find the solution/information you need. Once you have it, we would be happy if you could share your findings here and mark it as a solution. This will help other users find it in the future.

Thank you for helping us build our UiPath Community!

Cheers from your friendly
Forum_Staff

Thanks to UiPath support for pointing out the obvious :slight_smile: .

#1) Orchestrator 20.10 uses the JSON headers properly, earlier versions must have had a different behaviour, otherwise this typo would’ve surfaced earlier:

It has to be Content-Type !

#2 since the Header is now processed, the body really has to be JSON, so you need to ensure that your Body is converted to JSON:

#Step 1: define variables
$tenantName = “xx”#TenantName
$RPAuser =“xx”#RPAuser
$RPApassword = “xx”#RPApassword
$RPAAuthUri = “<LINK_TO_ORCH>/api/Account/Authenticate” #URI to obtain Bearer Token
$RPADataUri = “<LINK_TO_ORCH>/odata/Queues/UiPathODataSvc.AddQueueItem” #URI to send new queue item to

#Step 2: Get an authentication token from Orchestrator
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
$postBody = @{“tenancyName”=$tenantName;“usernameOrEmailAddress”=$RPAuser;“password”=$RPApassword}
$postBody = $postBody | ConvertTo-Json
$headers = @{“Content-Type”=“application/json”}

$response = Invoke-WebRequest -Uri $RPAAuthUri -Method POST -Headers $headers -UseBasicParsing -Body $postBody | ConvertFrom-Json;

Authentication is complete and I can create queue items from Powershell again!

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