HomeGuidesAPI ReferenceChangelogDiscussions
GuidesiMIS ProfessionaliMIS EnterpriseClient SupportLog In
Discussions

Discussions

Ask a Question
Back to All

Troubles with Offset and Count - /Persons Endpoint

Hi,

I've been running into a weird issue and need clarification if it's something I'm doing wrong, or if there's some underlying issue that I'm running into.

When attempting to get the List of Persons, via /Person endpoint, the Count, Limit and Offset don't seem to line up.

For instance, the below request to get 50 records, with the default offset (assumed to be 0). I've removed the Items but can include them if needed.

Request: https://reiqdev.imiscloud.com/api/Person?limit=50

Response:

{

"$type": "Asi.Soa.Core.DataContracts.PagedResult`1[[Asi.Soa.Membership.DataContracts.PersonData, Asi.Contracts]], Asi.Contracts",
"Items": {},
"Offset": 0,
"Limit": 50,
"Count": 42,
"TotalCount": 102760,
"NextPageLink": null,
"HasNext": true,
"NextOffset": 42
}

Why is the Count 42, if there's another 100k records?

Should that not be 50, the limit for this request?

This seems to repeat with inconsistent result, where requesting other limits such as 80, return other amounts for the count, such as 76.


Next one, the NextOffset from the first request is 42, so I add that as an offset to the request.

Request: https://reiqdev.imiscloud.com/api/Person?limit=50&offset=42

Response:

{
"$type": "Asi.Soa.Core.DataContracts.PagedResult`1[[Asi.Soa.Membership.DataContracts.PersonData, Asi.Contracts]], Asi.Contracts",
"Items": { },
"Offset": 0,
"Limit": 50,
"Count": 42,
"TotalCount": 102760,
"NextPageLink": null,
"HasNext": true,
"NextOffset": 42
}

The response shows offset 0, and the exact same count as last time.

Ok, maybe offset has to be a multiple of the limit, so trying offset 50 (we're still missing 8 records according to the count, so not sure where those go).

Request: https://reiqdev.imiscloud.com/api/Person?limit=50&offset=50

Response:

{
"$type": "Asi.Soa.Core.DataContracts.PagedResult`1[[Asi.Soa.Membership.DataContracts.PersonData, Asi.Contracts]], Asi.Contracts",
"Items": { },
"Offset": 50,
"Limit": 50,
"Count": 31,
"TotalCount": 102760,
"NextPageLink": null,
"HasNext": true,
"NextOffset": 81
}

Ok I've done 2 requests, which should have covered the first 100 records, and total amount of records retrieve of 81.


When I just use the default request (which should equate to limit 100, offset 0), the Count is different.

Request: https://reiqdev.imiscloud.com/api/Person

Response:

{
"$type": "Asi.Soa.Core.DataContracts.PagedResult`1[[Asi.Soa.Membership.DataContracts.PersonData, Asi.Contracts]], Asi.Contracts",
"Items": { },
"Offset": 0,
"Limit": 100,
"Count": 73,
"TotalCount": 102760,
"NextPageLink": null,
"HasNext": true,
"NextOffset": 73
}

So now I have 73 records, which is less than the count/NextOffset of the previous request, which confuses me.


Is this correct?

If yes, how should I be paginating the requests, if the response doesn't return the limit?

Contact us
Copyright © Advanced Solutions International, All rights reserved.