Jira API curl 401 error

Hey all,
Spun up a dev JIRA Cloud instance.

Tried to use curl to get API data and keep getting 401 not authorized

heres the curl command:

curl -D- -u :password -X GET -H “Content-Type: application/json” https://myurl.atlassian.net/rest/api/2/issue/

No matter what i try i get the dreaded 401!

This is for the JIRA instance not Confluence.

The end goal is to incorporate this into code later but first steps frist :slight_smile: curl

TIA

I’m not a curl expert, but I can maybe help with a couple of observations:

In requests, (such as POST or PUT), the Content-Type header tells the server what type of data is sent in the request. I don’t think you need that in your GET request. Maybe what you want instead is the Accept header.

The -u option should be followed by a user name, a colon, and then the corresponding password; for example -u bozo:clownface. I’m not sure if your question was merely omitting that bit for security.

I found a neat-oh curl builder at http://www.curl.build. I tried putting your options in there, and it generated this:

curl --verbose --header "Accept: application/json" --user 'bozo:clownface' --request "GET" "https://myurl.atlassian.net/rest/api/2/issue/"

David,
Thanks fro the suggestion!

I was able to figure it out finally.

curl -D- -X GET -H “Authorization: Basic base64String” -H “Content-Type: application/json” https://mystuff.atlassian.
net/rest/api/2/issue/

thanks!