SharePoint 2013 REST API Query Items with cross site lookup column
Recently, I had to query items using SharePoint 2013 Rest API (/api/web/lists/getbytitle('')/items). The problem that makes it hard is that it has a lookup column (Product) that looks up the items in a list from another web. The typical $filter statement (/_api/web/lists/getbytitle('Pages')/items?$select=Title,Id&$filter=Product eq 1) doesn't work.
After searching online and a few trial/error, I got it working by using /_api/web/lists/getbytitle('Pages')/items?$select=Title,Id,ProductId&$filter=Product eq 1
The ProductId field is automatically added to the list by SharePoint when you have a lookup field. You have to $select that ProductId and then you can filter the Product field. It's weird but it works.
After searching online and a few trial/error, I got it working by using /_api/web/lists/getbytitle('Pages')/items?$select=Title,Id,ProductId&$filter=Product eq 1
The ProductId field is automatically added to the list by SharePoint when you have a lookup field. You have to $select that ProductId and then you can filter the Product field. It's weird but it works.
Comments