Forums

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

Get updated issues that changed priority to "High" since given date - REST API

Jan Nowak June 12, 2019

I want to get all the issues that has been updated by changing their priority to "High" since given date, say "2019/06/01".

  • How would such a REST API call look like?
  • If this is not possible with REST API how can I achieve this in other way?

Thank you for any advice.

2 answers

1 accepted

1 vote
Answer accepted
Ismael Jimoh
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.
June 12, 2019

Hi @Jan Nowak ,

If you want issues that had their statuses changed to High, do I assume they are still high or these are changed back from high to another status?

If they remain in high status then you can try the below in the search issue page:

Updated >= "2019/06/01" AND priority = high

If they are changed back it gets tricky because the closest you get is (the JQL below is estimated and may not work so test):  

Updated >= "2019/06/01" AND (priority = high OR priority WAS high)

You still have operators that can be used to dig in deeper with operators like (Before, After, On, e.t.c.)  however this would require you know when this was changed as well else issues that were created a long time ago may pop up.

I would use 2 operators for changes on the specified day and one for changes after that day:

Updated >= "2019/06/01" AND (priority = high OR (priority was High ON startOfMonth()) OR priority was High AFTER startOfDay() )

 

If you cannot still find the correct query for yours you may want to consider checking the database changeitem/changegroup tables to pull this information.

Cheers.

Jan Nowak June 12, 2019

Hi @Ismael Jimoh ,

Thank you for the answer. I want to get issues:

  • updated after given date AND
  • this update involved change of priority to 'HIGH' (and they are still high)

 

  1. Now how would a well formed REST API url look like?
  2. Is there any way to transform the Jira Jql to working url string automatically?
Ismael Jimoh
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.
June 12, 2019

Hi @Jan Nowak 

With the standard JQL, you should be able to find issues that changed status to high like this:

Updated >= "2019/06/01" AND (priority = high and priority was not high BEFORE startOfMonth() )

 The above should give you all issues that are currently in the high status whose status changed around the date you specified (you should be able to replace the startofmonth() with a date).

Also, you can run a REST API JQL search using this API

Hope it helps.

Cheers.

Ismael Jimoh
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.
June 12, 2019

Hi @Jan Nowak 

With the standard JQL, you should be able to find issues that changed status to high like this:

Updated >= "2019/06/01" AND (priority = high and priority was not high BEFORE startOfMonth())

Also, you can run a REST API JQL search using this API.

Hope it helps.

Cheers.

Jan Nowak June 12, 2019

For anyone in the future:

To get the right string for url just copy from browser whenever you search within jira with jpq filter after `?` like: `?jql=....` or may export to xml and inside xml there is the encoded string.

0 votes
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.
June 12, 2019

Hi @Jan Nowak 

The basic API call that you would use is

/rest/api/3/search?expand=changelog&jql=project=XXX AND updated > "2019-06-01" AND ...

The important bit is expand=changelog which gives you the history of each issue. Add whatever JQL bits you need to specify the project, date etc.

Then, you will need to iterate through each returned issue, a C# example below will show you the structure of the JSON you need to work through

 foreach (var item in json.issues)


      foreach (var histories in item.changelog.histories)


              foreach (var history in histories.items)

You would be checking for 

history.fieldId=priority and history.toString=High

I hope this helps

Jan Nowak June 12, 2019

Hi @Warren ,

Thank you for the answer. Let me clarify please:

  1. If I want to get only those that has changed since given time and are still at priority "HIgh" how would the query look?
  2. Is it working only on api v3?
  3. Can this be done without this iterations?
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.
June 12, 2019

Hi @Jan Nowak 

  1. Add AND priority=High to the JQL section of the API call - this will only return items which are still at High
  2. No, you should be able to do the same (or similar) with v2
  3. I don't think so, you may be able to play around with the JQL that @Ismael Jimoh suggested and see if it gives you what you're after, but how will you know if it is returning all of them?

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events