For example, if the url for the GET request is this:

url: domain.com/_api/web/lists/getbytitle('Thing')/items?$select=*,Something/Field1A&$expand=Something/Field1

And if you're making multiple calls to grab different lists and one list happen to not have the Something field at all, instead of throwing an error and skipping over the whole request, is there a way to make these parameters optional? I have an array of lists that gets called one by one to retrieve their list items. There's a list that doesn't have that particular field so none of its items gets brought back. I'd like it where if that field doesn't exist, then it can just go ahead and get everything and not worry about it.

The reason I even have $select and $expand is because it's a lookup field and I need to get the user's name or else just the ID gets returned. Thanks.

Plus while writing this I wonder if using an if-else could work, but how would I know if the field exists before the request goes off.

1 Answer 1


If you don't explicitly know that these fields exist prior to calling the items endpoint, then it would be helpful to make a call like /_api/web/lists/getbytitle('Thing')/Fields and look for the desired fields. If they exist, then you can call your items endpoint with your select and expand params, otherwise you don't.

  • Would this be a separate call to retrieve Fields? Currently, I have two calls being done for each list - one for the list itself and another to get its list items. I'm worried about having an excessive amount of calls.
    – LaLaLottie
    Jul 28, 2016 at 16:21
  • It would be an additional call prior to making the call for the items, but you might be able to get it from your initial call to the list, idk what you are doing there. Jul 28, 2016 at 16:50
  • I get the list description from my call to the list. I'm looking around and it seems like you can only get the list fields by going through that specific endpoint you listed above? I couldn't just end it at naming the list and grab the fields that way?
    – LaLaLottie
    Jul 28, 2016 at 17:09
  • maybe altering your initial call to be /_api/web/lists/getbytitle('Thing')?$expand=Fields? Does this give you all the data you want? You'd just have to look in this to see if your field exists, then decide to do a select and expand on your next call or not. Jul 28, 2016 at 17:13
  • Thank you so much for everything! I'm going to run with this.
    – LaLaLottie
    Jul 28, 2016 at 17:21

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.