Hi Guys,
I have been connecting to jira enterprise for long time now and suddenly the invoke-webrequest powershell script with authorization header (with pat ) stops working and just throws unauthorized.
The same pat token works with c# code to call the rest api and even works with curl. Any help or idea will help me correct my invoke-webrequest because this was working before but not sure after which version of atlassian invoke-webrequest has stopped working.
My internal team is also not able to help either on this.
Community moderators have prevented the ability to post new answers.
This usually happens when PowerShell handles the `Authorization` header differently than curl or .NET clients. Jira Data Center expects a Basic auth header using the format `Authorization: Basic <base64encoded(username:token)>`, not the Bearer format used for OAuth. When using a personal access token (PAT), you still need to encode an empty username with the token, for example:
```
$pair = ":"
$encoded = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes($pair))
Invoke-WebRequest -Uri "</base64encoded(username:token)>
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.