Forums

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

Unable to fetch data using API - Search/jql

Chandra Kakkireni March 21, 2025

Hi Team,

 

Previously we used api/2/search to fetch data but it was deprecated. I tried accessing api/2/search/jql api but its not returning any data giving 200 success status but empty array.

Please let me know what i am missing

Thanks

curl --location 'https://{instance}/rest/api/3/search/jql?jql=issuetype%20%3D%20Epic%20ORDER%20BY%20created%20DESC' \ --header 'Authorization: Basic {api token}' \ 

5 answers

5 accepted

3 votes
Answer accepted
Chandra Kakkireni March 21, 2025

Thank you all. Issue was identified with help of Atlassian support team. Issue with Service account which i am using to get the data. Actually status was  confused me as it returning statuscode=200 and empty array

0 votes
Answer accepted
David Nickell
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 21, 2025

A couple of ideas:  

  1. Based on the JQL I see, you may simply need to use the URL Friendly version shown in your browser instead of the text with spaces in the JQL String

Rest Call.png

  1. Have you tried running your search URL/endpoint from a browser (e.g. Chrome)?  
  2. have you tried running a "myself" endpoint just to be sure your API Token has been properly encoded?  (the 200 status code would indicate that's not the problem).

If you can see the issues in Issue Navigator (eliminating any concerns about permissions), and you are getting a 200 status code -- I'm betting its the format of the JQL.   You can also do another test by using a filter Id  - e.g. search?jql=filter=99999.   

Good luck

 

 

 

0 votes
Answer accepted
Mahesh Shinde
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 21, 2025

Hi @Chandra Kakkireni ,

Please, find the attached document link which will correct way to perform the search using JQL.

https://confluence.atlassian.com/jirakb/how-to-return-issues-from-a-jql-query-using-rest-api-1289424308.html

Let me know if you have any issues.

Regards,

Mahesh Shinde

Chandra Kakkireni March 21, 2025

Hi Mahesh, i have followed same instructions exists in link, but no luck.

 

Previously we used to get the data using api/2/search but that api was deprecated.

Mahesh Shinde
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 21, 2025

Hi @Chandra Kakkireni

You are using Basic Auth where I can see token in postman page but username is missing, Can you check if you have added your user account in basic authentication?

Please, let me know if that's resolves your issues.

Regards,

Mahesh Shinde

0 votes
Answer accepted
Vishal Biyani
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 21, 2025

@Chandra Kakkireni 

Try something like this.


curl --request GET \ --url 'https://your-domain.atlassian.net/rest/api/3/search/jql?jql=project%20%3D%20HSP&nextPageToken=%3Cstring%3E&maxResults=100&fields=key,summary' \ --user 'email@example.com:<api_token>' \ --header 'Accept: application/json'

Chandra Kakkireni March 21, 2025

Hi Vishal, I have tried with user header , but no response from JIRA.

Status : 200 OK
{"issues":[]}

Vishal Biyani
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 21, 2025

Try with these 2 changes

  • remove &nextPageToken=<string> 
  • Add --header 'Authorization: Basic ...' instead of --user flag
Chandra Kakkireni March 21, 2025

Thanks Vishal for your reply.

Initially I have tried this approach only, but didn't get any data for below as well.

 

curl --location 'https://instancename/rest/api/3/search/jql?jql=project%20%3D%20%22CEE%22%20AND%20issuetype%20%3D%20Epic%20ORDER%20BY%20created%20DESC' \
--header 'Authorization: Basic {apitoken}' \

Vishal Biyani
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 21, 2025

please add below 2

--request GET 

--header 'Accept: application/json'

Vishal Biyani
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 21, 2025

This is my working curl. replace <your instance> and <encode_token>

This should work

curl --request GET \
--url 'https://<your instance>.atlassian.net/rest/api/3/search/jql?jql=project=CEE%20AND%20issuetype=Epic&maxResults=100&fields=summary%2Ccomment&expand=name' \
--header 'Accept: application/json' \
--header 'Authorization: Basic <encode_token>' \
--header 'content-type: application/json'

Chandra Kakkireni March 21, 2025

Hi Vishal, I have used same in postman but no luck. 

The Problem was it giving empty array, same JQL giving data at JIRA website level.

Chandra Kakkireni March 21, 2025

communityjira.png

Vishal Biyani
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 21, 2025

can you show the screen shot of your params?

Vishal Biyani
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 21, 2025

and make sure body is empty. 

Chandra Kakkireni March 21, 2025

Yes body is empty, and in params only jql was there like below image

 

Screenshot 2025-03-21 165336.png

Vishal Biyani
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 21, 2025

in params key, value add

maxResults 100

fields key,summary

and see if it makes a difference.

When you run the curl command in unix shell or git bash shell are you getting any output?

 

0 votes
Answer accepted
Nikola Perisic
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
March 21, 2025

Welcome @Chandra Kakkireni 

When you run this query in your actual Jira, does it return any results?

Chandra Kakkireni March 21, 2025

HI Nikola, Yes i copied the jql from JIRA itself. There it is returning data but from postman returning empty array

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
PREMIUM
TAGS
atlassian, atlassian government cloud, fedramp, webinar, register for webinar, atlassian cloud webinar, fedramp moderate offering, work faster with cloud

Unlocking the future with Atlassian Government Cloud ☁️

Atlassian Government Cloud has achieved FedRAMP Authorization at the Moderate level! Join our webinar to learn how you can accelerate mission success and move work forward faster in cloud, all while ensuring your critical data is secure.

Register Now
AUG Leaders

Atlassian Community Events