I have to load data from various lists with various views via SharePoint 2013 REST API. I have no knowledge about fields that are configured in views (general fields, custom fields, lookup fields, etc.).

I am able to determine which fields are on specific view:




{  "Id" : "89d0891d-b4a9-1111-1111-0881d8a35c0d",
    "Title" : "My First View",
    "ViewFields" : {
       "SchemaXml" : ..."Items" : {
       "results" : [ "Field1", "Field2", "w9ft", "q37c", "Field5" ]
{  "Id" : "89d0891d-b4a9-2222-2222-0881d8a35c0d",
   "Title" : "My Second View",
   "ViewFields" : {
       "SchemaXml" : ..."Items" : {
       "results" : [ "Field6", "Field7", "ab4tg", "Field9" ]

Problem is when I try to get the data from views, e.g. from "My First View":




{ "error": { ...
   "message": The query to field 'w9ft' is not valid. The $select query string must specify the target fields and the $expand query string must contains w9ft.

Which means that field w9ft is lookup field. In general, the same error can occur for any other field I have to load (Field1, Field2, etc.).

Therefore I need some mechanism how to determine which field is lookup field and add suffix Id to these field names (e.g. http://<myurl>/_api...$select=Field1Id,Field2,w9ftId,... ).

2 Answers 2


Following query should return Look up fields

/_api/web/lists/getByTitle('Your List Name')/Fields?$filter=TypeShortDescription eq 'Lookup (information already on this site)'

Conditions it will not work if you put ant custom description!

Update following will work in all scenario, I hope

/_api/web/lists/getByTitle('Your List Name')/Fields?$filter=TypeAsString eq 'Lookup' and ReadOnlyField eq false and Hidden eq false

To determine which fields are lookups you could take each field that is returned, e.g. "Field1", "Field2", "w9ft", "q37c", "Field5" and for each of these fields make REST calls to ascertain their type, like so:

http://<myurl>/_api/Web/Lists/getByTitle('MyList')/Fields?$select=TypeAsString&$filter=Title eq 'w9ft'

Or you can filter on the field's internal name with $filter=InternalName eq 'w9ft'

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.