Jira API Results for Changelogs Don't Match Jira UI

I am running the following code in PowerShell:

$urid = “https://xxx.atlassian.net/rest/api/latest/issue/YYY-3390/changelog
$c = Invoke-RestMethod $urid -Method ‘GET’ -Headers $headers

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?

I just found this in the Jira API documentation:

changelog Returns a list of recent updates to an issue, sorted by date, starting from the most recent.

How do I get ALL updates to an issue? Recent only does not help me.

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.

Thank you, David.

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.

This is not a maxResults paging issue.

Do you have examples of changes that appear in the UI but are not returned by the API? Is there any pattern in the rows that are not returned?

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.

But this does not help me.

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).

$uri = “https://xxx.atlassian.net/rest/api/latest/issue/YYYY-100/changelog?startAt=0&maxResults=100
$projectIssuePage = Invoke-RestMethod $uri -Method ‘GET’ -Headers $headers

self : https://xxx.atlassian.net/rest/api/2/issue/YYY-100/changelog?maxResults=100&startAt=0
maxResults : 100
startAt : 0
total : 21
isLast : True
values : {@{id=378263; author=; created=2018-08-03T10:04:44.211-0700; items=System.Object[]}, @{id=378298;
author=; created=2018-08-03T10:21:31.552-0700; items=System.Object[]}, @{id=379037; author=;
created=2018-08-06T10:23:39.936-0700; items=System.Object[]}, @{id=379218; author=;
created=2018-08-06T11:29:31.328-0700; items=System.Object[]}…}

The total above that says 21 but the Jira UI for this issue has 27 or 28 rows in its update history.

This is a limitation of the API call, it appears. It simply will not return all the change log data.

Thank you for your help, David, we will open a ticket with Atlassian.

Can you please post the answer here, once you receive it from Atlassian?

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.

No ticket submitted and this topic may be closed.

Thanks again, David.