Getting A Count Of Contacts From Outlook Office REST API - Javascript
Solution 1:
Sorry to hear that you're having trouble! There's a couple of things going on here.
It's troubling that you're getting a negative number back from the $count
call. If you go to https://oauthplay.azurewebsites.net and login with your account, do you get the same result from that call?
For paging, if all you want to do is get all the results, it is better to not rely on the $count
value. Instead, you should use the @odata.nextLink
value that comes back in the response to get the next page. Of course if you're trying to indicate to a user how many pages are there before getting all the results, the $count
is the way to do that.
Paging is controlled by the page size (the $top
parameter) and the "cursor" (the $skip parameter). If you're making a call to
/me/contactswith no parameters, then you're getting the default page size of 10 and default cursor of 0. You can use the
$top` parameter to request more results per page.
The @odata.nextLink
value will always return a URL you can use to get the next page based on the page size you specified in $top
(or 10 if you did not specify). Here's the value from doing GET https://outlook.office.com/api/v2.0/me/contacts
:
"@odata.nextLink": "https://outlook.office.com/api/v2.0/me/contacts/?%24skip=10"
This skips you ahead 10 results (based on the default page size of 10).
And here's the value from GET https://outlook.office.com/api/v2.0/me/contacts/?$top=20
:
"@odata.nextLink": "https://outlook.office.com/api/v2.0/me/contacts/?%24top=20&%24skip=20"
If there are no more pages, the @odata.nextLink
value will not be present in the response. So you can use that as your indicator to stop paging.
Post a Comment for "Getting A Count Of Contacts From Outlook Office REST API - Javascript"