Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Next challenges

Recent achievements

  • Global
  • Personal

Recognition

  • Give kudos
  • Received
  • Given

Leaderboard

  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

REST API not returning any data with API token Edited

Trying to fix an old script that used Basic Auth to connec to JIRA.
I see Basic Auth is no longer supported.

I read the following but although the queries return 200, they return no data.  

https://developer.atlassian.com/cloud/jira/platform/basic-auth-for-rest-apis/

 

Here is the curl and output when using "-u":

curl -D- \
 -u serge.prud.homme@erxxxxxn.com:COb....64A \
 -X GET \
 -H "Content-Type: application/json" \
 https://NAME.atlassian.net/rest/api/2/search?reporter=serge.prudhomme


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: Wed, 05 Feb 2020 13:22:12 GMT
atl-traceid: fbxxxxxxxxxxxxxx
x-arequestid: dfc1xxxxxxxxxxxxxxx8c3ea
x-xss-protection: 1; mode=block
timing-allow-origin: *
x-content-type-options: nosniff
set-cookie: atlassian.xsrf.token=BFK5-xxxxxxxxxxxxxxxxxxxxxxxx_lout; Path=/; Secure

{"startAt":0,"maxResults":50,"total":0,"issues":[]}


Same results if I try to create the header myself:

curl -D- \
 -X GET \
 -H "Authorization: Basic c2VyZ2UucHJ...2NSbWQ4OFF4TVAxbnJKS1AyNjRB" \
 -H "Content-Type: application/json" \
 https://NAME.atlassian.net/rest/api/2/search?reporter=serge.prudhomme


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: Wed, 05 Feb 2020 13:23:37 GMT
atl-traceid: 70xxxxxxxxxxxxxx
x-arequestid: fa0a03xxxxxxxxxxxxxxxxxxx
x-xss-protection: 1; mode=block
timing-allow-origin: *
x-content-type-options: nosniff
set-cookie: atlassian.xsrf.token=BFK5xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxt; Path=/; Secure

{"startAt":0,"maxResults":50,"total":0,"issues":[]}



1 answer

1 accepted

1 vote
Answer accepted
Dario B Atlassian Team Feb 11, 2020

Hi @Serge Prud'homme ,

Thanks a lot for pasting the curl output when executing the call. 

By looking at it I can see that:

  1. You are using an email address that is not present in the Jira instance you are sending the request to: the email address associated to your name in the given instance is serge.prudhomme@cxxx.xxx
  2. The syntax used to call the /rest/api/2/search endpoint is not correct, it should be: https://NAME.atlassian.net/rest/api/2/search?jql=reporter=serge.prudhomme

     

You can double check this by doing the following:

  • Send the exact same request with curl without providing any authentication credentials and see that the exact same response is returned:
    curl -D- -X GET https://NAME.atlassian.net/rest/api/2/search?reporter=serge.prudhomme
  • Send the above request but with the right syntax (adding jql= before the actual search query) will return a more meaningful error message:
    {"errorMessages":["Field 'reporter' does not exist or this field cannot be viewed by anonymous users."],"warningMessages":[]}
  • Try to log-into the Jira instance using the same email address (serge.prud.homme@exxxxxxx.xxx) and run the search from there. 

 

I hope this explains.

Also, I am going to edit your question in order to removed the sensitive data from there.

 

Cheers,
Dario 

Thanks for pointing out this silly mistake. I was using to the wrong user (I'm using multiple user ids and got mixed up)

Like Dario B likes this
Dario B Atlassian Team Feb 12, 2020

You are very welcome @Serge Prud'homme .

To be honest this happens to everyone that has multiple accounts, included me ;) 

As a good practice, when searching via REST API fails, always try to log-into Jira as the same user and try to run the same search. This usually helps to narrow down the possible causes for the issue (wrong account, missing proper rights, etc)

 

Cheers,
Dario

Suggest an answer

Log in or Sign up to answer
TAGS

Community Events

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

Events near you