Utilizing Scroll ID
Page detailing the use and usage of the scrollId
When querying the MXC APIs, you are limited to a maximum of 100 records per call. When retrieving more than 100 records you will need to use a "scrollId" in order to parse through the full number of records. The "export" routes for MXC APIs will allow you to perform this action; it is the required alternative to pagination and setting an offset with the "from" parameter that is also available. When you request, for instance, 150 records from an API, the first 100 will return along with a "_scroll_id": "some_long_hash_value" in the first response body. Take this string value and include it in the second request's payload. Use the same endpoint with the same parameters to complete the request for the remaining 50 records (do not change the "size" value).
Request:
Response:
{
"_scroll_id": "long_hash_value",
"totalRecords": [],
"recordCount": 100,
}
Send the second request to the same endpoint using the same parameters with the addition of the "_scroll_id" value into the request body in the following format:
Request:
POST: https://api.mxconnect.com/report/v1/tsys/disputes/export
Body:
{
"scrollId": "long_hash_value"
}
Receive the next set of records and copy the "_scroll_id" value from the previous request into the body of each subsequent request if there are more than two requests. Continue to append the "records" into your in-memory variable or write them to a file; however, you wish to hold the records in your application until all are returned.
This should allow your application to cycle through all authorizations from a specified time period without timing out or running into any connection limitations. The scrollId will hold the offset and update it as requests are made when the previous request completes.
Updated about 4 years ago