0

I'm using SharePoint Online and I'm trying to retrieve user photo making a request to userphoto.aspx with this URL:

var account = encodeURI(user@domain.tld);
return "https://mysharepoint.sharepoint.com/_layouts/15/userphoto.aspx?size=L&accountname="+account;

For some users this is working fine and I see the image correctly, for others it keeps returning the image like it is missing (but I checked and user added its own user photo).

The user who I am checking has never opened the company SharePoint site.

Any idea?

0

Test if images are present in SharePoint by using the below urls:

https://my-site-url/User Photos/Profile Pictures/david_contoso_onmicrosoft_com_MThumb.jpg

https://xxx.sharepoint.com/sites/dev/_api/SP.UserProfiles.PeopleManager/GetUserProfilePropertyFor(accountName=@v,propertyName='PictureURL')?@v='i:0%23.f|membership|user@xxx.onmicrosoft.com'

If still it does not return any pictur url, then I guess your sync between Exchange Online-SharePoint Online is broken. Check this article information on the sync.

  • Thank you. It seems if the user doesn't not open SharePoint Online, the photo still remains unavailable. Do you know if there's a way to force sync without force user to log in to SharePoint? – Pepozzo Oct 7 at 13:11
  • That is related to User Information List. And entry of the user is made only when user first time visits the site. – harshal gite Oct 7 at 14:25
  • I've opened SharePoint Online with another user (that has set its photo and I can see that photo on top right corner). I've waited about 24 hours but photo is still not available with Userphoto.aspx – Pepozzo Oct 8 at 9:04
0

You may have better luck using the Graph for this. Create a REST request in the contaxt of the user. https://docs.microsoft.com/en-us/graph/api/profilephoto-get?view=graph-rest-1.0

/me/photo/$value

or if it's for another user

/users/{id | userPrincipalName}/photo/$value

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.