5

I have a REST query that looks like this

/_api/lists/getbytitle('MainList')/items?$select=Title,LookupField/Id,LookupField/Title&$expand=LookupField

That works fine. But when I try to pull another field from the lookup list, I get an error. This query:

/_api/lists/getbytitle('MainList')/items?$select=Title,LookupField/Id,LookupField/Title,LookupField/CustomField&$expand=LookupField

Results in:

The query to field 'LookupField/CustomField' is not valid.

I should point out that if I try to pull in a standard field such as LookupField/Modified or LookupField/Created it works fine. It's only when I try to select a custom field that I get this error. Is that a limitation of the SharePoint API?

1
  • What is the type of your custom column? Commented Dec 22, 2016 at 17:51

1 Answer 1

6

When creating lookup field, you can select which field from source list you want to show. The number of such fields is limited by field type. For example you can create a lookup with lookup field pointed only to the following field types:

  • Single line of text
  • Date and Time
  • Number

Thus in your REST query you can select additional fields only with aforementioned field types.
For example you have a list Category with fields Title, Id, Active (custom Yes\No field). You created a lookup to Category in your other list.
Now what you have:

$select=category/Id,category/Title&$expand=category - works

and

$select=category/Id,category/Title,category/Active&$expand=category - doesn't work because Yes\No is unsupported field type for lookup.

1
  • Do you have an original source / documentation link that spells out these limitations? I've spent a long time searching and I can't find this stated anywhere. (It appears to be correct, but I like to be able to point people to official docs when possible.)
    – Coderer
    Commented Aug 10, 2020 at 14:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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