locked
pagination to get AllContacts RRS feed

  • 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;

    }

    }

    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

    Thursday, March 3, 2011 10:19 PM
    Moderator
  • 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 contacts
    Friday, 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;

    }

    }

    Friday, March 11, 2011 5:20 AM