Answered by:
pagination to get AllContacts

Question
-
Hi I have successfully obtained the access token through my own implementation and has gotten back the contact JSON back from Live server but I notice that the data returned does not contain all of the contacts, it only has the first 100.
Request was send as GET with the access token to:
http://apis.live.net/V4.1/cid-[CID]/Contacts/AllContacts?$type=portable
The JSON i got back has this bit of pagination-type info at the end
{ ......... , "itemsPerPage":100,"startIndex":0,"totalResults":100}
So my question is that what param I need to specify on the request URL to paginate to the next 100 contacts?
Thanks!
Thursday, March 3, 2011 5:16 PM
Answers
-
Hello,
Just put the get request statement in a loop like
while(true)
{
$response_array = json_decode(/* execute get request */ , true);
if($response_array['totalResults'] < 100 )
{
// this is the last page
break;
}
}
- Proposed as answer by Aditya Hajare Friday, March 11, 2011 6:30 AM
- Marked as answer by JOshiroModerator Friday, March 11, 2011 11:58 PM
Friday, March 11, 2011 5:20 AM
All replies
-
Have you tried:
http://apis.live.net/V4.1/cid-[CID]/Contacts/AllContacts?$type=portable&$skip=100
- Proposed as answer by JOshiroModerator Thursday, March 3, 2011 10:29 PM
Thursday, March 3, 2011 10:19 PMModerator -
But how do I know the "total" number of contacts in order to me to know if i have reached the end? The totalResults in the JSON is always 100 when I have more than a 100 contactsFriday, March 4, 2011 6:27 AM
-
Bump.Sunday, March 6, 2011 6:02 AM
-
Hello,
Just put the get request statement in a loop like
while(true)
{
$response_array = json_decode(/* execute get request */ , true);
if($response_array['totalResults'] < 100 )
{
// this is the last page
break;
}
}
- Proposed as answer by Aditya Hajare Friday, March 11, 2011 6:30 AM
- Marked as answer by JOshiroModerator Friday, March 11, 2011 11:58 PM
Friday, March 11, 2011 5:20 AM