1

I have created a field of type Person or Group with "show field picture only". When I look at the result I get back from the _api/web URL what I see is this as the field name:

<d:OData__x0061_wo9Id m:type="Edm.Int32">25</d:OData__x0061_wo9Id> 

I need to get the right properties like username,accontname etc..out and I think need to build this url below:

/_layouts/15/userphoto.aspx?size=M&accountname=name%40domain.com.au&url=https%3A%2F%2Fdomain-my.sharepoint.com%3A443%2FUser%2520Photos%2FProfile%2520Pictures%2Fusername_domain_com_au_MThumb.jpg

to be able to get each users picture.

Thanks in advance

  • What is your end goal? The link to the picture, or the user's profile info? – wjervis Oct 6 '14 at 13:26
5

For User field types you could specify $expand query option to return projected fields. In case of User fields the additional properties will be retrieved from User Information List.

Assume Approver is a single-valued User field. Then the following REST request will return Approver field properties such as Id,Name,Title:

/_api/Web/Lists/getByTitle('<list title>')/items?$select=Approver/Id,Approver/Name,Approver/Title&$expand=Approver

How to retrieve User Picture using SharePoint REST

Since User Information List contains Picture field, the following query demonstrates how to retrieve Picture for a specific user:

/_api/Web/Lists/getByTitle('User Information List')/items?$filter=Id eq <user id>&$select=Picture

where <user id> is the id of User

Note: The returned value is of SP.FieldUrlValue type:

{
   Url: '<url>',
   Description: '<description>'
}  

References

Use OData query operations in SharePoint REST requests

  • Thanks for the query Vadim.But i can i just get the link to the picture – naijacoder Oct 7 '14 at 11:25
  • The answer has been updated, see the section: How to retrieve User Picture using SharePoint REST – Vadim Gremyachev Oct 8 '14 at 7:10
  • 1
    The problem with this is the User Information List can only be queried via REST if the currently logged in user has admin access to the site. Is there a way to get the photo URL of any user without the user needing admin access? – Submits Aug 25 '16 at 8:31
  • 1
    To have this work with different language packs, better use /_api/Web/SiteUserInfoList/Items?$filter=Id eq <user id>, because the Title of this list varies between language packs. Also this should solve @Submits access troubles. – Hinek Mar 29 '17 at 7:11

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.