Invoke-webrequest : The remote server returned an error: (401) Unauthorized

I’m trying to run the below command in powershell and I keep getting "The remote server returned an error: (401) Unauthorized."
When I run the URL on browser it comes back with the correct results. Any idea where I might be going wrong?

invoke-webrequest -uri “http:///octopus/api/interruptions?regarding=Deployments-2423”


Hi binh,

You are not passing anything to the -header parameter of invoke-webrequest in that example you sent. If you don’t send a header with an x-Octopus-apikey key on it, you’ll always be getting (401) Unauthorized cause you are not authenticating yourself agains the Octopus Server.

Check any example in the below repository to see how to add the header to your request: