How to create a PowerShell script to Upload a process .nupkg file via Rest API to Orchestrator?

hi All,

I am trying to create a powershell script to upload a .nupkg to orchestrator tenant using API call. Below is my script:

$bodyAccount = @{
“tenancyName” = “Automation_tenant”
“usernameOrEmailAddress” = “test_user1”
“password” = “Test@1234”
} | ConvertTo-Json

$contentType = “application/json;charset=utf-8”

$uriAccount = “https://uipath.xx.xx.xx.xx/api/Account/Authenticate

$resAccount = Invoke-RestMethod -Uri $uriAccount -Method Post -Body $bodyAccount -ContentType $contentType


$uriUpload = “

$boundary = “----PowerShellBoundary”
$contentType = “multipart/form-data; boundary=$boundary”

$resPkgUpd = Invoke-RestMethod -Uri $uriUpload -Method Post -Headers @{“accept”= “application/json”; “Authorization”=“Bearer $authKey”} -ContentType $contentType -InFile “C:\TEMP\TestSumit.1.0.3.nupkg”

The issue is below which i am getting:

Invoke-RestMethod : {“message”:"Failed to read the request form. Unexpected end of Stream, the content may have already been read by another component. ",“errorCode”:0,“traceId”:“00-71494df4062861fccee6804fb5efb119-cb78c9df6b828c5d-00”,“resourceIds”:null}
At C:\Users\sughosh\OneDrive - Capgemini\Documents\powershell scripts\uipath orchestrator\test.ps1:22 char:14

  • … resPkgUpd = Invoke-RestMethod -Uri $uriUpload -Method Post -Headers @ …
  •             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    • CategoryInfo : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-RestMethod], WebException
    • FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeRestMethodCommand

can someone help me out on what is the issue. The authentication is successfull though and is failing while trying to upload the file.

Using curl, the file upload is getting successfully completed though as can be seen below from the response:

C:\Users\sughosh>curl -X POST “” -H “accept: application/json” -H “authorization: Bearer xxx” -H “Content-Type: multipart/form-data” -F “file=”@C:\TEMP\TestSumit.1.0.3.nupkg"


Please help out

Hi @Sumit_Ghosh1,

It is nice to see that you tried to get it done yourself! Kudos.

Good luck! You are going to enjoy doing this!