简体   繁体   中英

Get Multiple Lookup field for a ListItem in Microsoft Graph

I have a lookup column that allows multiple values per item. I use the Microsoft Graph .NET SDK to retrieve all the column values for a list item:

ListItem item = await graphClient.Sites[siteId].Drive.Items[itemId].ListItem.Fields.Request().GetAsync();

I also tried to retrieve the lookup column specifically:

var queryOptions = new List<QueryOption>()
{
   new QueryOption("expand", "fields(select=MultipleLookupColumn)"))
};
ListItem item = await graphClient.Sites[siteId].Drive.Items[itemId].ListItem.Request(queryOptions).GetAsync();

It correctly shows the column values, including custom columns, except for the multiple lookup column. The lookup column shows up in item.Fields.AdditionalData , but it is always an empty array, even when there are values assigned to it on Sharepoint Online. But if I change the lookup column to disallow multiple values, it shows the value correctly.

How can I get the values of a multiple lookup column using the Graph API? Or are multiple lookup values not supported?

I found that it is a permissions issue. I had it set up with the Files.ReadWrite.All permission, which is sufficient for reading the document library and files in Sharepoint Online, including lookup columns with single values. But unfortunately not lookup columns with multiple values. Once I added the Sites.Read.All permission, the multiple lookup values array was no longer empty.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM