The total from the API returns, say, 30, but when I open the “YYY-3390” ticket in the Jira UI and count the history rows, I get 50. This appears to be the case for many, but not all, issues returned from the Jira API.
I was expecting to get all history for this issue but it appears only the recent change logs are shown?
You still want to use GET /rest/api/2/issue/{issueIdOrKey}/changelog, which returns all changes, but the results a paginated (just like about every Jira Cloud REST API) - see the startAt and maxResults parameters. Also, know that maxResults is capped - see https://developer.atlassian.com/cloud/jira/platform/rest/v2/#expansion for a way to measure the cap for maxResults.
I am paging this, pulling 50 rows at at time, and putting the rows into a PSObject, and that code is working. I am getting the rows the API is giving me but it is not the complete set as shown in the Jira UI.
That was my thinking as well, that there may be a pattern. The missing rows are not due to differing ChangelogItemField values (e.g., Epic Link, Fix Version, Sprint, etc).
It appears only the most recent change log rows are served up by the API. I’ve proven this with several older issues: the recent changes are shown but the older ones are not.
This is a big problem as I need the full history of the issues, not just the recent updates. For what it’s worth, the documentation does state:
changelog Returns a list of recent updates to an issue, sorted by date, starting from the most recent.
Well, I don’t know what you mean by “recent”, but I can see changes dating back to 2016 on some issues. And I can also get more than 100 changes from issues. Maybe you want to double-check your code? For example, make sure you start the next page at startAt+result.maxResults - don’t assume the maxResults you passed is the one Jira uses, and use the one Jira returns instead.
I mean that only the most recent change logs for the issue are shown by the API; the older ones are not.
This is the code I’m running, set to start at 0 and return 100 results. Running the same query starting at 100 and returning 100 results returns no data (i.e. all of the data is in the first call starting at 0).
It looks like this was an issue in my code but not related to paging. One has to loop over the histories and then the issues; I was trying to use one counter for both and was dropping issues as a result.