0

I have 2 lists: Questions and Answers. Questions has a single lookup to Answers. Answers has a single choice column called Category. I would like to query Questions, expand its Answer and select the Answers Category.

I thought this would be simple like it was in 2010 and tried these:

/_api/web/lists/getByTitle('Questions')/items?$filter=Id eq 2&$expand=Answer&$select=Id,Answer/Category

/_api/web/lists/getByTitle('Questions')/items?$filter=Id eq 2&$expand=Answer&$select=Id,Answer/CategoryValue

but I get the error:

The query to field 'Answer/Category' is not valid.`

How can this be done in the new REST APIs?

2

In SharePoint, the lookup column cannot "lookup" choice type , so the error would occur when using REST API to get the choice column with lookup column. However, the lookup column can lookup values in calculated column, so you can get calculated column value with same API.

So if you want to get the choice column value, you need to get the ID of the item first with the REST API and then use item ID to get the choice column or use a calculated column instead.

FYI - You can only retrieve text, number or date values through lookup field similar to when you create a lookup column via UI and choose what additional properties you want to include.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.