Reputation: 430
I am currently trying to grab all user information using the Microsoft Graph API and I was wondering if there was a more concise way of also grabbing a users photos to replace what I am currently doing.
I am currently doing the following;
Grab user details by calling https://graph.microsoft.com/beta/users?$expand=manager
NOTE: I am using the beta API as I cannot seem to get the manager data back otherwise.
Iterate over users and then for each user call https://graph.microsoft.com/beta/users/{user_id}/photos
For each photo returned I am then;
https://graph.microsoft.com/beta/users/{user_id}/photos/{photo_id}
to get the meta data (e.g. id, height and width). NOTE: I have found the height and width on the initial photos are not always correct whereas they are on this call (so I use this one only for the details)https://graph.microsoft.com/beta/users/{user_id}/photos/{photo_id}/$value
to get the image.This results in lots of individual API calls on top of the users query;
This could quickly get substantial with a large organisation utilizing multiple profile pictures per person for different sizes.
Is there a way of expanding the photo data within the initial users call to avoid having to do all of these additional API calls?
Thanks, John
Upvotes: 2
Views: 1925
Reputation: 5838
Couple of things here John.
GET https://graph.microsoft.com/v1.0/me/photos
API is basically a way for you to see what photo sizes are available. You can optimize which size you want, based on your experience - for example if it's a mobile device you might select the smallest (or second smallest size). If it's for a desktop device, you might select the largest size. Requesting GET https://graph.microsoft.com/v1.0/me/photo
(note the singular) will get the metadata for the largest available photo. The smaller sizes are scaled versions of the largest photo. In some circumstances, only one size is available. Please see details here. So I'm not sure why you need to get every profile photo size (it's the same photo, but different sizes).Hope this helps,
Upvotes: 2