I was following this instruction to use curl to retrieve JIRA issues (https://developer.atlassian.com/cloud/jira/software/jira-rest-api-basic-authentication/ ).
I was able to use -u "email_adrres:API_token" (return with JSON data ) but I was not able to use Basic authentication (401 error). I used the decoded "email_adrres:API_token" with basic 64
You cited the Jira Server documentation, but your question is tagged with a Jira-cloud question. This is confusing, because the documentation for one platform does not always apply exactly to the other. If you're using Jira Cloud, then I would recommend trying to follow the steps in https://developer.atlassian.com/cloud/jira/software/jira-rest-api-basic-authentication/ instead.
If this doesn't help, could you let us know more about which way you're trying to make this REST call? (using curl, postman, or some other utility for examples) I would be interested to see the specific syntax you are trying to use here if you're using curl for example.
Thanks for pointing that out. However, in this case the command is the same with curl (Linux). I was trying to use basic auth headers method.
I first encode the email_address:API_token with this command (on linux):
openssl enc -base64 <<< "email@example.com:API token"
then I use this curl command ( the below command is just the example from the doc) :
curl -D- \ -X GET \ -H "Authorization: Basic ZnJlZDpmcmVk" \ -H "Content-Type: application/json" \ "https://your-domain.atlassian.net/rest/api/2/issue/QA-31"
Then I got the 401 error.
However, I am able to get the JSON data when i use this command:
curl -D- \ -u firstname.lastname@example.org:api_token \ -X GET \ -H "Content-Type: application/json" \
Thanks for letting me know the steps you are taking here. I think I can see the problem now. The method you are using to encode the string is known to include an additional carriage return. Check out this comment https://superuser.com/questions/120796/how-to-encode-base64-via-command-line/133253#133253
From that thread:
Openssl can be used more succinctly:
echo -n 'input' | openssl base64
[ echo -n -> must be used, or encoding will be done including new line character ]
I tried this in my own command line. I noticed that when I use the steps you followed (and when I excluded the '-n' parameter from this method), I got an additional 4 characters on the end of my encoded string. However when I used the command line statement of:
echo -n 'email@example.com:apitokenstring' | openssl base64
The encoded string was 4 characters shorter than with your steps or without the -n. It looks like the carriage return is getting added to your string and in turn throwing off the string.
I hope this helps.
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