1

Is there an alternative to _api/web/siteusers or _api/web/sitegroups that is able to return both groups and users?

I'm looking for a way to return the person OR group title from a SharePoint item using getbyid().

I want a single solution that can return the title whether it's a group or a person. Is this possible?

2
  • Are you trying to fetch items from SharePoint list (_api/web/lists/getbytitle('')/items) with person or group column? Commented Mar 8, 2023 at 8:28
  • I am checking to see how things are going there on this issue. Commented Apr 6, 2023 at 6:05

1 Answer 1

0

If you are trying to fetch person or group column details from SharePoint list items, use SharePoint REST API endpoint in below format:

https://contoso.sharepoint.com/sites/siteName/_api/web/lists/getbytitle('List Name')/items?$select=Title,PersonColumn/Title&$expand=PersonColumn

It will return correct title for both the cases correctly.

List data:

enter image description here

REST API Output (example):

<link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/PersonColumn" type="application/atom+xml;type=entry" title="PersonColumn" href="Web/Lists(guid'7568b3cc-bbab-4582-a5ad-51b465d92869')/Items(1)/PersonColumn">
    <m:inline>
        <entry>
            <category term="SP.Data.UserInfoItem" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme" />
            <content type="application/xml">
                <m:properties>
                    <d:Title>Megan Bowen</d:Title>
                </m:properties>
            </content>
        </entry>
    </m:inline>
</link>
<content type="application/xml">
    <m:properties>
        <d:Title>Item 1</d:Title>
    </m:properties>
</content>

<link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/PersonColumn" type="application/atom+xml;type=entry" title="PersonColumn" href="Web/Lists(guid'7568b3cc-bbab-4582-a5ad-51b465d92869')/Items(1)/PersonColumn">
    <m:inline>
        <entry>
            <category term="SP.Data.UserInfoItem" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme" />
            <content type="application/xml">
                <m:properties>
                    <d:Title>JSONFormatting Members</d:Title>
                </m:properties>
            </content>
        </entry>
    </m:inline>
</link>
<content type="application/xml">
    <m:properties>
        <d:Title>Item 2</d:Title>
    </m:properties>
</content>

OR If you want user or group title from SharePoint site directly, you can query hidden User Information List using endpoint like:

https://contoso.sharepoint.com/sites/siteName/_api/web/lists/getbytitle('User Information List')/items?$select=Title,Id
2
  • @peter How would the call format look if the Person or Group column was called the following: 'Dean of School/College, Vice President of Division or Vice Provost' Commented Mar 8, 2023 at 16:36
  • You have to use the internal name of your column in place of PersonColumn in above endpoint. Follow this to find internal name: plumsail.com/docs/help-desk-o365/v1.x/How%20To/… Commented Mar 8, 2023 at 17:15

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.