I have a column which type is SPGroup
in a list. I want to get items via SharePoint REST API
, and I only need the items which SPGroup
contains the current user. So what's the URL? Thank you for your advice!
You can use the $expand
parameter in your REST query to include related entities of data in your query, but since the SharePoint REST service implements the OData protocol, the $filter
method can only be invoked on the top level item, thus making it impossible to use on an expanded field.
Depending on how many items your list contains, I'd suggest that you either try to filter it on something other than the current user, or fetch everything and filters the result in your code instead.
A REST query would look something like this:
http://sp/_api/web/lists/getbytitle('MyList')/items?$select=Id,Title,Members/Id&$expand=Members
where Members
is the SPGroup
to be expanded.
In each item that is returned, you will get something like
<content type="application/xml">
<m:properties>
<d:Id m:type="Edm.Int32">60</d:Id>
</m:properties>
</content>
with the Id
value of the member. From this, you should be able to write some custom code to filter out only the items that contain the current logged in user.