SharePoint REST Get User Title in a single REST query

只谈情不闲聊 提交于 2019-12-03 01:47:40

Using $expand OData operator you can specify that the request returns projected fields from other lists and the values of lookups.

The following REST endpoint:

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

returns Title and Name for Author column in 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"
        }
    }
}

You can use the below rest query to get the modified by user's title: /_api/web/lists/getbytitle('Pages')/items(1)?$select=Editor/Name,Editor/Title&$expand=Editor/Id

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!