Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

O365 REST API clarification

I'm trying to work out what I'm doing wrong. I'm trying to get all the contacts from O365 in a XML or JSON format so I started looking into it and found out that Microsoft has a API which will return the data in JSON (perfect!).

The API is accessible at: https://outlook.office365.com/api/v1.0/me/contacts I opened the link in a browser, and all was OK, except that it only returns the first 10 contacts. I do not need this to be incorporated into any kind of software or program or anything I just need to get it trough the browser. Am I missing something or is there any other way how I can get all the contacts flushed in a very basic format?

Thanks for any tip.

like image 714
Emil Borconi Avatar asked Feb 20 '26 00:02

Emil Borconi


1 Answers

The default for the API is to return only 10 entries per request. You can increase this up to 50. For larger result sets you have to use paging. http://msdn.microsoft.com/office/office365/APi/complex-types-for-mail-contacts-calendar#UseODataqueryparametersPageresults

So in the browser, you could do: https://outlook.office365.com/api/v1.0/me/contacts/$count

That would tell you how many total you have. Then you can grab the first 50: https://outlook.office365.com/api/v1.0/me/contacts?$top=50

If you have more, you can grab the next 50 with the $skip parameter: https://outlook.office365.com/api/v1.0/me/contacts?$top=50&$skip=50

And so on.

like image 77
Jason Johnston Avatar answered Feb 24 '26 05:02

Jason Johnston