Reputation: 464
I'm attempting to pull all users within a specific group and to also get their transitive membership.
The endpoint I am hitting is:
https://graph.microsoft.com/v1.0/groups/{id}/transitiveMembers/microsoft.graph.user?$select=givenName,surname,country,city,companyName,officeLocation,displayName,mail,department,jobTitle,employeeId&$expand=transitiveMemberOf
This pulls the data I need, but there is an object of OData type microsoft.graph.group
in the returned payload that causes the following error:
A resource of type 'microsoft.graph.group' was found in a resource set that otherwise has entries of type 'microsoft.graph.user'. In OData, all entries in a resource set must have a common base type.
Which then causes a JSON parse error of unexpected token
. The response does contain the next link and I would like to be able to handle this error and move on to the next page. However, the JSON::ParserError prevents me from doing this.
Any ideas what might cause a microsoft.graph.group
object to be returned when microsoft.graph.user
was specified in the request url?
Upvotes: 3
Views: 2806
Reputation: 10372
The solution for me was to add the $count=true query parameter and setting the ConsistencyLevel header. This made the error go away and the call succeed.
It even says so in the documentation:
Whoops. Both the header and the query parameter are needed as of writing this.
Upvotes: 2