If you've been using the events API, you may have noticed that the pages of history that you see in Mingle and the pages of the XML files returned by the API script don't necessarily match up. In order to find all of the information that you are looking for, you might need to navigate through the XML feed to other pages.
The pages are in reverse order, so page 1 is most likely the oldest page. So how do you figure out what page number is the most current so that you can move to the next page in line?
To start, use the current URL to get all of the events.
For example:
URL = 'https://erin.mingle-api.thoughtworks.com/api/v2/projects/to_do/feeds/events.xml? rel="current"'
At the top of the returned XML page, you will see three links. One is to the current page (the most recent page), one is to the self page (whatever page we're looking at right now), and one is to the next page and it includes the page number.
For example:
<link href="https://erin.mingle-api.thoughtworks.com/api/v2/projects/to_do/feeds/events.xml" rel="current"/>
<link href="https://erin.mingle-api.thoughtworks.com/api/v2/projects/to_do/feeds/events.xml" rel="self"/>
<link href="https://erin.mingle-api.thoughtworks.com/api/v2/projects/to_do/feeds/events.xml?page=25" rel="next"/>
In this example, my current page must be number 26, and the next page for me to navigate to is page 25.
When I change the URL in my script to reference page 25,, I now have 4 links at the top of my XML page. The current, self, next and now the previous page are listed.
<link href="https://erin.mingle-api.thoughtworks.com/api/v2/projects/to_do/feeds/events.xml" rel="current"/>
<link href="https://erin.mingle-api.thoughtworks.com/api/v2/projects/to_do/feeds/events.xml?page=25" rel="self"/>
<link href="https://erin.mingle-api.thoughtworks.com/api/v2/projects/to_do/feeds/events.xml?page=24" rel="next"/>
<link href="https://erin.mingle-api.thoughtworks.com/api/v2/projects/to_do/feeds/events.xml?page=26" rel="previous"/>
I can navigate further back by changing the URL to page 24 if I choose to, or I can return to the most current page (26).
If you are interested, you can find more API example scripts created by Product Specialist Sarah Barnekow at this GitHub repo. Please file any issues via GitHub.
Do you have any other tips and tricks for using the Mingle API? Let us know in the comments below.
Comments
0 comments
Please sign in to leave a comment.