2

Let's say I have the query:

http://thisbox/_api/lists/getbytitle('ThisList')/items?$select=* 

But instead of "*" for selecting fields, I have a list of Field Internal Names and/or GUID's. I'd like to use to select from (I can retrieve either from elsewhere in my code). However the SELECT option seems to want to get only external (Visible) field names. Thoughts?

3
  • what happend when you provide the internal name in you query? seems to be working for me. what type of fields you trying to access it?
    – Waqas Sarwar MVP
    Apr 30, 2015 at 20:29
  • For example on a "Modified by" field which has a typical internal name of "Editor" in an internal list: /items?$select=Editor returns "The query to field 'Editor' is not valid. The $select query string must specify the target fields and the $expand query string must contains Editor
    – tekiegreg
    Apr 30, 2015 at 20:39
  • @tekiegreg, see my answer (section: About deferred fields) Apr 30, 2015 at 21:30

3 Answers 3

1

your first REST query should work as long as internal name of the position column is same. You can check by running below query which will display the metadata for columns along with their columns.

http://thisbox/_api/lists/getbytitle('ThisList')/items

you will see something like this:

<d:User_x0020_ModifiedId m:type="Edm.Int32">12</d:User_x0020_ModifiedId>

Now you run the query like this.

http://thisbox/_api/lists/getbytitle('ThisList')/items?$select=User_x0020_ModifiedId 
7

The query /_api/lists/getbytitle('<list title>')/items?$select=* returns list items for visible fields only (SP.Field.hidden property is set to false).

To be more precise the expression $select=* returns:

  • visible fields values (query that returns visible field names: /_api/Web/Lists/getByTitle('<list title>')/fields?$select=InternalName&$filter=Hidden eq false)
  • FileSystemObjectType hidden field value
  • not all visible field values are returned, for example ItemChildCount is not available:

How to return an additional fields

In order to return an additional fields, the field name(s) have to be specified explicitly using $select query option. For example, to return hidden system field FileRef you could utilize the following query:

/_api/Web/Lists/getByTitle('<list title>')/items?$select=FileRef

or

/_api/Web/Lists/getByTitle('<list title>')/items?$select=FileRef,*

While the first query will return only a single FileRef field value, the latter query will return list field values plus FileRef field value.

About deferred fields

For some field types such as SP.FieldUser or SP.FieldLookup $select expressions returns only the identifier (ID) of the list item that this field is referring to. For example, the query: /_api/Web/Lists/getByTitle('<list title>')/items for Editor field returns only user id (EditorId)
For that case $expand query option comes to the rescue that is intended for retrieving projected fields, for example the query:

/_api/Web/Lists/getByTitle('<list title>')/items?$select=Editor/Title,Editor/Id&$expand=Editor 

returns Title and Id properties of Editor field

2

Not a direct way. Select only responds to the name/GUID. You would have to do an additional pull to

http://thisbox/_api/lists/getbytitle('ThisList')/Fields

in order to return the list of names, internal names and GUIDs and cross-reference accordingly.

Your Answer

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

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