I have a list with one lookup field and a large amount of other custom columns. I need to retrieve all the fields but only my custom columns without to specifiy them becouse the solution needs to be dynamic.

I use REST api for SP 2013 and this is my url so far:

url + "/_api/lists/getbytitle('myListTitle')/items/?$select=process/Title&$expand=process/Title

Is their any solution so i dont need to specify all my columns in $select query?

  • Can you be more clear how you want the $select be dynamic? – Emiliano Poggi Nov 2 '15 at 14:32
  • I wonder if it is possible to retrive all my custom columns without to specify them? – Anders Nov 2 '15 at 14:35
  • You can. But you will miss lookup column's info – Atish Dipongkor - MVP Nov 2 '15 at 14:41

I would try with this approach:

  1. Use Field Colleciton Endpoint to retrieve all the fields of your list. You can filter fields by checking their READONLY and HIDDEN properties. If they are true, probably they are system fields.
  2. On success, generate your $select string dynamically on the base of the result and then execute the get call.
  • To expand on this, you can use the FromBaseType property to find 'custom' fields that are not part of a content type with an endpoint like /_api/web/lists/getByTitle('Children')/fields?$filter=((FromBaseType eq false) and (Hidden eq false)) or (StaticName eq 'Title') if you do have them inheriting from a content type you can look for that content type in the field item – John-M Nov 2 '15 at 15:36
  • 1
    It worked! Great solution. – Anders Nov 3 '15 at 12:50

It is not possible to use $expand without $select. In the $select, it is needed to specify all the columns you are need. I have tried to get items from following URL without $select.

/_api/web/lists/GetByTitle('List Name')/Items?$expand=LooKUp/Title


    "error": {
        "code": "-1, Microsoft.SharePoint.SPException",
        "message": {
            "lang": "en-US",
            "value": "The query to field 'LooKUp' is not valid. The $select query string must specify the target fields and the $expand query string must contains LooKUp."

Following end-point should give you all custom columns without expanding lookups

/_api/web/lists/GetByTitle('List Name')/Items

Above end-point will give you lookup column's ID. If you need any information from this lookup column, the you have to make an another GET with this ID. Following end-point can be used for getting lookup column's info.

/_api/web/lists/GetByTitle('listname')/GetItemById('lookup column id')

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.