0

I have written my app, in SharePoint Framework, but in link I have got only name of list. How can I get user name and Surname of editor and creator?

enter image description here

I want to have all user data. How can I get it by using Rest API?

2

1 Answer 1

2

You can use REST endpoint like:

<siteUrl>/_api/web/lists/getbytitle('TestList')/items(1)?$select=Title,Author/ID,Author/Title,Author/LastName,Editor/ID,Editor/Title,Editor/LastName&$expand=Author,Editor

This will give you:

  • Author ID
  • Author Title (Full Name)
  • Author LastName
  • Editor ID
  • Editor Title (Full Name)
  • Editor LastName

Then using ID you got from above endpoint, you can request profile picture like:

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

OR using SP.UserProfiles.PeopleManager (Check 2nd reference link):

/_api/SP.UserProfiles.PeopleManager/GetPropertiesFor(accountName=@v)?@v='<accountName>'&$select=PictureUrl

References:

  1. How to get users picture field displayed via _api/Web/Lists - SharePoint Online
  2. How to Retrieve User Profile Properties(eg Picture) Using REST SharePoint
2
  • Great, but how get this user to the code. Please @Ganesh Sonap
    – Grzegorz Z
    Mar 2, 2021 at 7:07
  • 1
    You can call first (/items) endpoint, which will give you the list items & respective author/editor ID. Then in success function of first API call, inside for loop (for each result), you can get the profile picture for respective user by passing ID you got from 1st API call. Mar 2, 2021 at 7:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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