Forums

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

Rest API - get issues between dates

yesoh November 25, 2019

Hi,

I am trying to get issues created between two dates. How I'm currently doing is basically using api call to run jql query (POST, /rest/api/2/search), getting the ticket id from the result, then running another rest api call (GET, /rest/api/2issue/{id}) with the ids replaced.

It works perfectly fine, but it just takes long to process the data if the dates are far apart. Is there any alternative to achieve the same thing? I have to get issues because Jql query results are just not detailed enough for my purpose :(

Thanks

1 answer

1 accepted

0 votes
Answer accepted
Warren
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.
November 26, 2019

Hi @yesoh 

Just as an aside before I answer the question, you say you're using POST for step 1. Why? Surely it's also a GET?

What I think you're trying to do, can be done via this one call :

/rest/api/2/search?jql=createdDate > "2019-01-01" AND createdDate < "2019-11-30"

where you can put in the applicable start and end dates for your search

yesoh November 26, 2019

Hello,

I use POST because I'm pulling over 1000> tickets for the data, and it was recommended to use POST for larger data set.

And that's basically what I have for the first api call. But as mentioned above, the data is not detailed enough, for example, I need some of the customfields, worklogs, etc.

Warren
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.
November 26, 2019

Hi @yesoh 

Okay, it depends on what data you're after - you mention customfields and worklogs.

  • Customfields show in the response that I get using the search call - possibly not all of them, I haven't checked
  • Worklogs can be obtained using expand=changelog using the search call

If there are other fields that you require that aren't coming through, then to speed up the initial call, add 

&fields=key

to your initial search call, so that for each issue it returns a much smaller set of data, because key is the only item you need. That initial call should hopefully be a bit quicker.

yesoh November 26, 2019

Thanks so much! Specifying the fields really helped. :)

Suggest an answer

Log in or Sign up to answer