SharePoint REST Get user name in one REST request

I have a list that has the People and Group column. when I request rows using REST, I get the user IDs listed in this column.

I found this article that will help me convert each identifier to a title

http://www.codeproject.com/Articles/692289/How-to-Get-Login-Name-and-Display-Name-using-Sha

But I am wondering if there is a way to get the user header with one REST call (instead of getting the identifier first and then making another call to convert the identifier into the display username and login)

+4
source share
2 answers

Using the $expandOData operator , you can specify that the query returns projected fields from other lists and search values.

The following REST endpoint:

/_api/web/lists/getbytitle('Pages')/items(1)?$select=Author/Name,Author/Title&$expand=Author/Id

returns Titleand Namea column Authorin the pages list

{
    "d": {
        "__metadata": {
            "id": "63b9e943-6398-4b6d-acc9-fc4f554f78df",
            "uri": "https://contoso.sharepoint.com/_api/Web/Lists(guid'be43ccf2-5ca7-4957-bf81-7cdc86744d9b')/Items(1)",
            "etag": "\"6\"",
            "type": "SP.Data.PagesItem"
        },
        "Author": {
            "__metadata": {
                "id": "8e4ad44e-f6f0-4dcc-92c6-78dc3d2c68af",
                "type": "SP.Data.UserInfoItem"
            },
            "Name": "i:0#.f|membership|username@contoso.onmicrosoft.com",
            "Title": "John Doe"
        }
    }
}
+14
source

You can use the query below to get the change by user name: / _api / web / lists / getbytitle ('Pages') / items (1) $ = select Editor / Name, editor / Title &? $ = Expand Editor / Id

+1
source

Source: https://habr.com/ru/post/1532188/


All Articles