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.
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
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?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.