7

I have a web api 2.2 that is configured for OData v4. I want to return a user by ID and include only the user group Id's that the user is a member of. When I do this

http://localhost/User?$filter=id eq 312&$select=*,userGroups/id&$expand=userGroups

I get this error

The query specified in the URI is not valid. Found a path with multiple navigation properties in a select clause. Please reword your query such that each level of select or expand only contains either TypeSegments or Properties.

Found a path with multiple navigation properties in a select clause. Please reword your query such that each level of select or expand only contains either TypeSegments or Properties.

The query will execute if I remove ",userGruops/id"

Brett
  • 321
  • 4
  • 15

2 Answers2

5

You should write your query like this:

http://localhost/User?$filter=id eq 312&$select=*&$expand=userGroups($select=id)

By the way, you can also remove the $select=* segment as all non-navigation properties are by default included in the response.

Yi Ding - MSFT
  • 2,864
  • 16
  • 16
  • This works perfectly. I don't think Microsoft follows the OData specifications perfectly though. Thanks – Brett Nov 26 '14 at 14:51
  • 2
    @BrettFeagans I'm from OData team of Microsoft and I'm well connected to our college working on the URL parser in ODataLib. Would you shed light on what exactly isn't followed perfectly enough? We'd love to hear your feedback and improve our stack accordingly. – Yi Ding - MSFT Nov 27 '14 at 02:11
  • 2
    @Yi Ding - FSFT / @Microsoft OData team This: `https://graph.microsoft.com/v1.0/users?$select=*&$expand=manager($select=id)` gives the error: "Invalid $select properties" While this: `https://graph.microsoft.com/v1.0/users?$expand=manager&$select=id,displayName,manager/id` gives the error: "Parsing OData Select and Expand failed: Found a path with multiple navigation properties or a bad complex property path in a select clause. Please reword your query such that each level of select or expand only contains either TypeSegments or Properties." – VinnyQ77 Apr 07 '21 at 06:36
0

The Beta version of the API handles

https://graph.microsoft.com/beta/users?$select=id,surname&$expand=manager($select=id)
strattonn
  • 1,790
  • 2
  • 22
  • 41