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?

5
  • Are you getting any error while calling this endpoint ? Commented Apr 24, 2020 at 12:44
  • There are no errors. I am getting the concerned record, but the lookup fields are showing some _deferred entry
    – entryton
    Commented Apr 24, 2020 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. Commented Apr 24, 2020 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
    Commented Apr 24, 2020 at 14:48
  • Great. Glad it helped you. Please Upvote and accept it as an answer as it helped you. Commented Apr 24, 2020 at 15:06

1 Answer 1

0

Try your endpoint like:

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

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.