REST API Changelog

Andrew Zibuda
Contributor
October 26, 2018

Based on this article, you should be able to get the FULL changelog of an issue using get('/rest/api/2/issue/key/changelog')

 

When I try to use that it only gives me the 100 oldest changes. Any that were made past the first 100 are not returned. Is this article just incorrect? And if so is there ANY way to get the entire changelog for an issue?

1 answer

1 accepted

2 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.
October 26, 2018

Hi Andrew

Have you tried, as per the directions in the article, to work through more than just the first page? (i.e. the first 100?)

Andrew Zibuda
Contributor
October 26, 2018

Using the ScriptRunner Script Console I return the entire Changelog result of the Get request, and it only shows 100 changes. Would it not return the entire thing this way?

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.
October 26, 2018

I know I tried answering this question, but I only have Jira cloud and have never used ScriptRunner.

I suspect that it would be the same as when I use the REST API directly, which is limited in what it returns. Look at the beginning of the returned JSON and there should be some of :

startAt

maxResults

lastPage

These should give you a hint as to what is returned

Andrew Zibuda
Contributor
October 26, 2018

Yes I see what you mean there...I have tried adding ?maxResults=200 at the end of the query to get more but that doesn't seem to work. I'm able to access the end-results by adding ?startAt=100 or so but that isn't ideal since issues will have different size changelogs and would need to start elsewhere to get the proper changes...any idea how to change maxResults or otherwise get around this?

 

I suppose I could do an initial query to get the size of the Changelog and then adjust the startAt location accordingly and do another query but that seems inefficient

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.
October 26, 2018

Hi Andrew

If they've said that it only returns 100 per page, you could put maxResults=10000 and you'd still only get 100.

In the header section there is usually a variable (possibly called total?) which tells you exactly how many records there are. So let's say you're trying to get 243 records :

Your first call will be ?startAt=0&maxResults=100 which gives you records 0 - 99

Your next call will be ?startAt=100&maxResults=100 giving records 100 - 199

Checking that 199 < total, your next call is ?startAt=200&maxResults=100 giving you records 200 - 242.

242 > total, so now you have them all :)

Like # people like this

Suggest an answer

Log in or Sign up to answer