I have a Blazor web app (interactive server rendering mode) in C# on .NET 8.0 and I want to access files in a Sharepoint Online document library.
I can read the list of files from Sharepoint using the MS Graph API call to
GET https://graph.microsoft.com/v1.0/drives/{driveId}/items/root/childrenand I get back a list of driveItem objects from Sharepoint. This works just fine.
My document library also defines some additional custom fields (additional metadata about the files) that users need to fill in, and I can access this using the relationship from the driveItem to the corresponding listItem and then that list item's relationship to the fields field value set:
GET https://graph.microsoft.com/v1.0/drives/{driveId}/items/{itemId}/listItems/fieldsThat also works like a charm - I get all my additional custom metadata fields.
Now, however - I would like to update some of those metadata values - or add new ones. The listItem relationship property on the driveItem is defined as read-only - so that won't work for an update.
BUT: I was able to grab the list.id and the listItem.id from the response, and I then tried to update that listItem (where the fields relationship property isn't defined as read-only) using:
PATCH https://graph.microsoft.com/v1.0/sites/{siteId}/lists/{listId}/items/{listItemId}/fieldsContent-Type: application/json{"MyField": "My new value"}However, unfortunately, I only get this error back:
"error": {
"code": "generalException",
"message": "General exception while processing",
"innerError": {
"date": "2024-08-08T20:40:23",
"request-id": "fb68589f-9afd-4eec-8b68-d56cb18e69bd",
"client-request-id": "fb68589f-9afd-4eec-8b68-d56cb18e69bd"
} }
That isn't very clear and very helpful - not clear on what's going on here... is there anyone who's stumbled across this same problem and has found a solution for it?