› Dynamics 365, Enterprise › Issue faces in retrieving 5000+ records using Web API
Issue faces in retrieving 5000+ records using Web API
While using Fetchxml queries to retrieve more than 5000 records, first page will give you 5000 records and paging cookie. Paging cookie will help to retrieve additional records. For additional records, we need to set the paging cookie in the fetch tag.
Setting the paging cookie:
When the fetch query is executed it brings the paging- cookie with it in the resultant response. The paging cookie is attached to the next Fetch XML
The paging cookie consists of the first and last record details. Name and the GUID of the records.
When trying to execute fetch XML request. it started throwing “Page Cookie Malformed” exception. This is because there is a special character present in the paging Cookie.
You can see in the above cookie that Name has “&” which is the replacement for character “&”. This breaks the fetchXml request.There can be any character present in the record name such as (‘s). Even (‘) breaks the fetch XML.
Thus, we need to encode the paging-cookie before it is inserted in fetchXml.
This will help to solve the issue and we can retrieve more than 5000 records.
Liked it? Share it.