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?


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


or if it's for another user

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

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


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.

  • 1
    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 '19 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. Oct 7 '19 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 '19 at 9:04

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.