Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Powershell Invoke-RestMethod returns 401

For starters
I'm very new to the world of web requests, REST, and APIs, and only have limited experience with Powershell, so it may be that I'm missing something very obvious to the trained eye.

I can make a REST call in Postman, to our Jira Cloud instance, and the the results of a query to our knowledgebase.

Basically this URL:

When trying to do the samething with Invoke-RestMethod in Powershell I keep getting a 401 Unauthorized response.

The things I've tried
Read through every hit on the first couple of pages on Google and Bing (because you never know), but haven't found anything that made it clear to me.

My code
Gracefully stolen from someone with a similar issue, who got it to work like this.

$user = [System.Text.Encoding]::UTF8.GetBytes("")
$headers = @{Authorization = "basic" + [System.Convert]::ToBase64String($user)}

Invoke-RestMethod -Uri "" -Method GET -Headers $headers -ContentType "application/json"


Why Powershell?
I want to create a one-stop-script for creating new projects, and access to our instance is managed by groups in Azure AD. We already have a script for creating those groups, and this would be a continuation of that script.

This is just me learning. The GET call is just to help me get a better understanding of working with REST calls in Powershell.

1 answer

1 accepted

1 vote
Answer accepted


I woke my laptop up from sleep mode, noticed a capital B in "Basic", changed it to lower case, looked at headers in Postman, noticed that the Authorization header had "Basic" with a capital B in the value, changed it back to capital B in my script.
Then I ran the script to remind myself what error message I was getting, and now it works.

I don't know why, but for some reason it works.

Hey @Rune Rasmussen ,

Glad you figured this one out and a big thank you for sharing the solution you found.

And I too am not 100% sure on what is happening here but the third party applications are doing some case conversion in the background causing a conflict for the auth header and its a mind your p's and q' moment, but I had helped on a similar case with postman with a similar issue on case sensitivity in "basic" depending on whether you're currently logged in or not, and I wanted to link it here as a reference point in case anyone else is hitting the same issue:


Suggest an answer

Log in or Sign up to answer
Community showcase
Published in Jira Service Management

Security Advisory for Jira Service Management

On October 20, 2021, Atlassian published a security advisory for Jira Service Management. The full advisory is available at this link.  We've seen a number of questions already asking for...

242 views 1 2
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you