1

I am trying to build a software using jenkins and after the build I need to upload the files to a webserver with an API using command line. I have tried Invoke-WebRequest but have no luck with it.

Invoke-WebRequest -Header @{"{"X-Octopus-ApiKey"="<APIKEY>"} -Method Post  -InFile 'file.zip' -Uri http://example.com/api/packages/raw

Using the above command I am always getting 400 Bad Request

Invoke-WebRequest : The remote server returned an error: (400) Bad Request.
At line:1 char:1
+ Invoke-WebRequest -Headers @{"X-Octopus-ApiKey"="API-P5CI8B7HKR460OPA ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo          : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-WebRequest], WebException
+ FullyQualifiedErrorId :WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeWebRequestCommand

Any idea how to make this work?

zozo6015
  • 131
  • 1
  • 5

0 Answers0