Reputation: 239
I have 2 sharepoint lists setup to represent different groups(circles) and the users that are apart of those groups(circles).
List: Circles Columns: Circle(single line of text)
List: UserCircles Columns: UserName(person lookup), UserCirlce(lookup to Circle list)
In the setup, all of the columns are their own columns (I have not renamed the title column to Circle or anything like that). I have not changed the display names of the lists.
When I try to run an REST GET against the UserCircles list and retrieve the projected values from the Circles list as below:
/_api/web/lists/getbytitle('UserCircles')/items?$select=Circles/Circle&$expand=Circles
I get a HTTP 400 Error and the message: The field or property 'Circles' does not exist
I can successfully run a query against the UserName field (I assume that's the referenced field), by running the below query:
/_api/web/lists/getbytitle('UserCircles')/items?$select=Author/Title&$expand=Author
I am not sure why the query cannot find the list specified. I have verified all of the list names. Any guidance would be appreciated.
Upvotes: 1
Views: 2098
Reputation: 59338
There is a typo in your example, since the name of lookup field is UserCirlce
, the query should be like this:
/_api/web/lists/getbytitle('UserCircles')/items?$select=UserCirlce/Circle&$expand=UserCirlce
Note: the name of lookup field have to be specified in
$expand
query option
The list of examples for syntax's of $expand
query option:
/_api/web/lists/getbytitle('<listtitle>')/items?$select=<lookupfieldname>/<projectedfieldname>&$expand=<lookupfieldname>
/_api/web/lists/getbytitle('<listtitle>')/items?$select=<lookupfieldname>/<projectedfieldname1>,<lookupfieldname>/<projectedfieldname2>&$expand=<lookupfieldname>
Upvotes: 1