Forums

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

Unable to use API anymore, after normal Basic Authorization depricated

Maxim Nikitenko
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!
July 22, 2019 edited

I use Jira cloud and i had a script which checked tickets assigned to me, but today was unable to use this script as Jira API started to response with 401 error, i read about it and it seems that username and password basic auth is deprecated from now on, no problem i've created API key, but when i run requests like:

/rest/api/2/search?jql=assignee=username+order+by+priority

i still get 400 code response with this inside:

{"errorMessages":["Field 'assignee' does not exist or this field cannot be viewed by anonymous users.","Not able to sort using field 'priority'."],"warningMessages":[]}

but in list of API key i see that key been used just recently, which means API recognize my key, what i do wrong way?

1 answer

1 accepted

0 votes
Answer accepted
Dario B
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
July 23, 2019 edited

Hello @Maxim Nikitenko ,

If I understand correctly the script used to work and now it suddenly stopped.

If this is the case, then it can be because you are using the username to search and this has been removed due to GDPR compliance (and this would explain why you get error  400 - bad request):

 

Specifically, this change is documented in: https://developer.atlassian.com/cloud/jira/platform/deprecation-notice-user-privacy-api-migration-guide/#search

Request query parameter changes

  • JQL will not allow username or userKey in queries. Use accountId instead.

To help you update your JQL queries, we’ve introduced a new operation: POST /rest/api/3/jql/pdcleaner which takes one or more JQL queries with user identifiers and converts them to equivalent JQL queries with account IDs.

 

Therefore, after the change you can only use: emailAddress, accountId or displayName to search for users.

 

Now, can you kindly test the below curl command and see if it works for you:

curl -D- -u <EMAIL-ADDRESS>:<API-TOKEN> https://<CLOUD-URL>/rest/api/2/search?assignee=<EMAIL-ADDRESS-2>

Replace <EMAIL-ADDRESS> and <API-TOKEN> with your email address and API Token,  <CLOUD-URL> with the url for your Jira Cloud instance and <EMAIL-ADDRESS-2> with the email address of the user you are searching for in the assignee field.

 

If this command is still not working, please paste the output in here removing the  sensitive data like, e.g.:

curl -D- -u xxxxxxx@atlassian.com:xxxxxxxxxx https://xxxxxxxx.atlassian.net/rest/api/2/search?assignee=xxxxxxx@atlassian.com

HTTP/2 200 
server: AtlassianProxy/1.15.8.1
vary: Accept-Encoding
cache-control: no-cache, no-store, no-transform
content-type: application/json;charset=UTF-8
strict-transport-security: max-age=315360000; includeSubDomains; preload
date: Tue, 23 Jul 2019 09:21:05 GMT
atl-traceid: 8705xxxxxxxxx
x-aaccountid: 557057xxxxxxxxxxxxxxxxxxxxxxxxxxxx
x-arequestid: cee5f562xxxxxxxxxxxxxxxxxxxxxxxxx
x-xss-protection: 1; mode=block
timing-allow-origin: *
x-content-type-options: nosniff
set-cookie: atlassian.xsrf.token=xxxxxxxxxxxxxxxxxxxxxxxxx
 

{"expand":"schema,names","startAt":0,"maxResults":50,"total":51,"issues":[{"expand":"operations,versionedRepresentations,editmeta,changelog,renderedFields","id":"10526","self":"https://xxxxxxxxx.atlassian.net/rest/api/2/issue/10526","key":"TSP-23","fields":{"statuscategorychangedate":"2019-06-19T16:36:09.484+0200".......
[...]

 

Cheers,
Dario

Maxim Nikitenko
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!
July 23, 2019

Yes, thats right, i replaced account_id with email and it started working as usual, thanks!

Like Dario B likes this
Dario B
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
July 23, 2019

I am happy to know this helped @Maxim Nikitenko 

Please do not hesitate opening a new thread in case of any other question.

Cheers,
Dario 

Suggest an answer

Log in or Sign up to answer
TAGS
atlassian, atlassian community, loom ai, atlassian loom ai, loom, atlassian ai, record recaps of meetings, meeting recaps, loom recaps, share meeting recaps,

Loom’s guide to great meetings 📹

Join us to learn how your team can stay fully engaged in meetings without worrying about writing everything down. Dive into Loom's newest feature, Loom AI for meetings, which automatically takes notes and tracks action items.

Register today!
AUG Leaders

Atlassian Community Events