401 Unauthorized

I’m receiving a 401 Unauthorized error when trying to post attachments to the Jira Cloud.

Everything works just fine on hosted server. What’s wrong?

Hosted

POST /rest/api/2/issue/:id/attachments
{ 
  'Authorization': "Basic #{Base64.encode64(name + ':' + password)}",
  'X-Atlassian-Token': 'no-check' 
}
=> 200 OK

Cloud:

POST /rest/api/2/issue/:id/attachments
{ 
  'Authorization': "Basic #{Base64.encode64(email + ':' + password)}",
  'X-Atlassian-Token': 'no-check'
}
=> 401 UNAUTHORIZED

Earlier this year Atlassian moved Cloud customers to an Atlassian Account. We’ve discovered some painpoints in that move specifically with calling REST API endpoints with Basic Authentication.

Read this page for further details https://confluence.atlassian.com/cloud/the-upgrade-to-atlassian-account-873871204.html

Some troubleshooting tips:

  • Make sure you’re using your Atlassian Account credentials instead of SAML credentials if you have that setup.
  • Log into your Atlassian account id.atlassian.com and try changing your password.

Let me know if that helps.

Thanks,
Ralph

2 Likes

As you suggested, I changed my login, logged out and then logged back in.

I was able to get things working by defining the following headers:

headers = {
  'Authorization': "Basic #{auth}",
  'X-Atlassian-Token': 'no-check'
}

where

auth = Base64.encode64(email + ':' + password)

The values of email and password are those for the admin user.

Thanks for the tip!

1 Like