i have a small requirement, where in i am pulling in a lot of data from List A to List B through Rest API. but i am stuck at one place where in i am not able to pull in lookup value in List B.
Hope you guys can help me out.
You need to use the &$expand=[Column internalname]
and the &$Select=[Column internalname]/Id
url parameter to get the Id of the lookup item, if you need the text value from the lookup use /Title instead of /Id.
I have a lookup to a list, the column name in list which contains the lookup is "Sync", so my REST call is like this:
/_api/web/lists(guid'1B51700E-D95D-46C5-9B9B-1386CCCC07DB')/items?$select=Title,Sync/Id&$expand=Sync
This returns the value from the column "Titel"and the id of the lookup column "Sync".
You can use the below call to expand columns
/_api/web/lists(guid'<guid>')/items?$select=Title,LookupField1/FieldToBeExpanded1,LookupField2/FieldToBeExpanded2&$expand=LookupField1,LookupField2