4
votes

I have a SharePoint(Online) list which has around 50 columns. Out of which 6 are lookup columns. I am trying to write a REST query to get all the columns including the expansion($expand) of lookup columns. Specifying all the columns in '$select' will make the REST query URL to exceed the limit allowed by IE. But to expand the lookup columns I need to specify them in the '$select'.

?$select=col1,col2,col3/Title,col4/Title.....,col54&$expand=col3,col4

Is there a way to access all columns from the lists without making multiple request to the server?

1
Take a look at the SP PnP JS framework. It simplifies the process of using ajax requests to fetch list data and it also supports expand. Just add the pnp.min.js file to your solution and then access the 'pnp' object with $pnpJackson

1 Answers

6
votes

you can try using * for all the columns.

In below example, * has been used to get all the columns. Country and State are lookup columns so they have been used along with * as they are part of $expand.

https://site/_api/lists/getbytitle('TestLookup')/items?$select=*,Country/Title,State/Title&$expand=Country/Id,State/Id