0

I am using REST api to fetch data from a SharePoint list.

I am able to get data using this query:

requestUri = "/_api/lists/GetByTitle('Data')/items?$select=ID,Title,Department/Title&$expand=Department

However when I use this query:

requestUri = "/_api/lists/GetByTitle('Data')/items(6)"

Or this query:

requestUri = "/_api/lists/GetByTitle('Data')/items?$select=ID,Title,Department/Title&$expand=Department&$filter=ID eq 6"

I am not getting the data from the lookup fields.

What could be going wrong here?

  • Are you getting any error while calling this endpoint ? – Ganesh Sanap Apr 24 '20 at 12:44
  • There are no errors. I am getting the concerned record, but the lookup fields are showing some _deferred entry – entryton Apr 24 '20 at 12:50
  • You should get the lookup data in data.d.results[0].Department.Title. Also check if there is any department selected for item with ID=6. – Ganesh Sanap Apr 24 '20 at 14:37
  • Holy!! I chose some random ID, and all the 10 lookup fields were empty for that particular record. Changed the ID, and it is working.. – entryton Apr 24 '20 at 14:48
  • Great. Glad it helped you. Please Upvote and accept it as an answer as it helped you. – Ganesh Sanap Apr 24 '20 at 15:06
0

Try your endpoint like:

requestUri = "/_api/web/lists/GetByTitle('Data')/items(6)?$select=ID,Title,Department/Title&$expand=Department
  • This doesn't resolve the issue. – entryton Apr 24 '20 at 12:50

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.