my last test was on 29th Mar 2019 and it was worked well and good at that time.
when I tried to used same queries today getting 401 error and remining all queries too, then used CURL command getting same response, now nothing is working
curl -D- -u <email>:<password> -X GET -H "Content-Type: application/json" http://<domain>.atlassian.net/rest/api/2/search?jql=project=<projectname>&fields=id,key&startAt=1&maxResults=1
curl --request GET --url 'https://<domain>.atlassian.net/rest/api/2/search?jql=project=<projectname>&fields=id,key&startAt=1&maxResults=1' --header 'Authorization: Basic <auth token>' --header 'Accept: application/json'
please advice what is wrong here
Hi Suresh,
Atlassian's Jira Cloud has deprecated the use of plaintext passwords for basic auth type REST API requests. More details are in https://developer.atlassian.com/cloud/jira/platform/deprecation-notice-basic-auth-and-cookie-based-auth/
In place of using a clear text password, you can still use basic auth, but you will need to create an API Token for your account and use this instead. Follow the instructions here to generate an API token. That Token is not a direct replacement for the password, but there are steps you need to follow to do this in https://developer.atlassian.com/cloud/jira/platform/jira-rest-api-basic-authentication/
From that page:
Supplying basic auth headersIf you need to, you may construct and send basic auth headers yourself. To do this you need to perform the following steps:
- Generate an API token for Jira using your Atlassian Account: https://id.atlassian.com/manage/api-tokens.
- Build a string of the form
useremail:api_token
.- BASE64 encode the string.
- Supply an
Authorization
header with contentBasic
followed by the encoded string. For example, the stringfred:fred
encodes toZnJlZDpmcmVk
in base64, so you would make the request as follows:
1 2 3 4 5
curl -D- \ -X GET \ -H "Authorization: Basic ZnJlZDpmcmVk" \ -H "Content-Type: application/json" \ "https://your-domain.atlassian.net/rest/api/2/issue/QA-31"
Instead of using the -u switch, you would need to use the -H and encode your useremail:api_token into a base64 string, and then use that string as the example above explains.
I hope this helps.
Andy
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.