I have a lookup column in Sharepoint Online 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 multiple 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.
So I tried to send an HTTP GET request to see if it is an issue with the SDK. Unfortunately, the resulting JSON also shows an empty array, which means that it is an issue with the Graph API itself. For example, with the column MultiLookup
:
"fields": {
"@odata.etag": "\"acf66f85-cc5e-4dcf-a276-e4e5edf5e758,21\"",
"FileLeafRef": "file.pdf",
"MultiLookup": [],
"MultiLookup_x003a_Created": [],
"id": "31",
"ContentType": "Document",
"Created": "2021-05-31T19:43:03Z",
"AuthorLookupId": "10",
"Modified": "2021-06-02T13:06:52Z",
"EditorLookupId": "12",
"_CheckinComment": "",
"LinkFilenameNoMenu": "file.pdf",
"LinkFilename": "file.pdf",
"DocIcon": "pdf",
"FileSizeDisplay": "31151",
"ItemChildCount": "0",
"FolderChildCount": "0",
"_ComplianceFlags": "",
"_ComplianceTag": "",
"_ComplianceTagWrittenTime": "",
"_ComplianceTagUserId": "",
"_CommentCount": "",
"_LikeCount": "",
"_DisplayName": "",
"AppAuthorLookupId": "12",
"Edit": "0",
"_UIVersionString": "21.0",
"ParentVersionStringLookupId": "31",
"ParentLeafNameLookupId": "31"
}
To make sure that it is a bug specific to the Graph API, I also tried getting the lookup values from the old Sharepoint REST API:
https://{site_url}/_api/Web/Lists(guid'{guid_id}')/Items({item_id})
With the old Sharepoint REST API, I was able to get the lookup values, although the column is called MultiLookupId
instead of MultiLookup
.
<d:MultiLookupId m:type="Collection(Edm.Int32)"><d:element>5</d:element><d:element>10</d:element><d:element>11</d:element></d:MultiLookupId>
Unfortunately, the old REST API only works on my browser when I am signed in. When I tried to call the old API programmatically with the same access token that I use for Microsoft Graph API, I get an Unauthorized (401)
error.
At this point, I am fairly certain that this is a bug in the Microsoft Graph API. Is this an easy fix for the Microsoft dev team, or there another way I can retrieve the multi-lookup column values?