Reputation: 290
I am using REST api to fetch data from a SharePoint list.
I am able to get the lookup fields 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?
Upvotes: 1
Views: 2009
Reputation: 290
The issue was found.
Figured out that I was fetching an item for which all the lookup fields were blank.
I fetched another item, and data was returned as expected.
Upvotes: 0
Reputation: 3615
I tested with the endpoint, it works:
/_api/web/lists/GetByTitle('ListName')/items(1)?$select=ID,Title,Department/Title&$expand=Department
Compared the url with yours in original question, only append web behind /_api, it should be working.
Upvotes: 1