Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Authentication required to perform this operation

Nick Kennedy
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
September 4, 2020

Hi - I am trying to run a simple script to create a project from our server when a webhook is fired from another software. The documentation says that basic authentication using API keys is supported but when using the endpoint I need I get a 401.

{"errorMessages":["You are not authenticated. Authentication required to perform this operation."],"errors":{}} 

This is the command I need to work

https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-projects/#api-rest-api-3-project-post

When I run the following curl request with the same credentials I get a 200 response but the values array is empty and the `total` value is 0. However If I navigate to the returned 'self' link in the browser I can see the result with 'total' being 12 and the values array populated.

curl --request GET \
  --url 'https://your-domain.atlassian.com/rest/api/3/project/search' \
  --user '<my user ID>:<my API key generated here: https://id.atlassian.com/manage-profile/security/api-tokens>' \
  --header 'Accept: application/json'

Any guidance on why the post endpoint is returning a 401 error would be greatly appreciated.

2 answers

0 votes
Andy Heinzer
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
September 25, 2020

Hi Nick,

I see that you are trying to make a REST API call to Jira Cloud here, but getting a 401 error.  Technically you can no longer pass the API token in this manner.   When you use the -u in curl, this is being seen like a login attempt that would normally have a username and password passed to it.  Atlassian deprecated the support of password in basic auth last year.  I know you're not using a password here, but our services aren't going to work with that format of a request now.  At one point in the past, our services would accept an API token as a password, but no longer.

But it is still possible to make requests using Basic auth with the API Token.  The trick here is to first build a string of

emailAddress:APItoken

and then base64 encode that string.  You can then pass that encoded string in an authorization header instead of using the -u in curl.  Steps to do this are in Basic auth for REST APIs.

Try this and let me know if you run into any problems with this.

Andy

0 votes
Sramanth Pandeti
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 4, 2020

Hi @Nick Kennedy Welcome to the Atlassian Community!

Can you try using your Jira email address instead of user ID in the username section and see if it's working?

Nick Kennedy
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
September 7, 2020

Hi @Sramanth Pandeti

I tried this and received a warning about email addresses not being allowed to be visible in GDPR strict mode. Is there a way for me to disable GDPR strict mode and test this again using email in place of user ID?

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
FREE
TAGS
AUG Leaders

Atlassian Community Events