1

I'm struggling upgrading to Microsoft SDK 5.3.0. This code is suppose to set a value to a specific column for a DriveItem.

string key = "SomeColHeader";
string value = "Value1";
             
var fieldValueSet = new FieldValueSet
{
  AdditionalData = new Dictionary<string, object>()
  {
    {key, value}
  }
};

await GraphClient
   .Drives[driveId]
   .Items[driveItemId]
   .ListItem.Fields
   .Request()
   .UpdateAsync(fieldValueSet)

Any help appriciated.

Marc LaFleur
  • 31,987
  • 4
  • 37
  • 63

1 Answers1

3

First thing, it's definitely a bug in v 5.3.0 that it's not possible to update FieldValueSet when you access the list item through the endpoint

PATCH /v1.0/drives/{driveId}/items/{driveItemId}/listItem

As an alternative get listItem and select parentReference and sharepointIds properties. Then access listItem through /sites endpoint

var listItem = await client
           .Drives[driveId]
           .Items[driveItemId]
           .ListItem.GetAsync(x=>
           {
               x.QueryParameters.Select = new[] { "id", "parentReference", "sharepointIds" }; 
           });

var result = await client.Sites[listItem.ParentReference.SiteId]
          .Lists[listItem.SharepointIds.ListId]
          .Items[listItem.Id]
          .Fields
          .PatchAsync(fieldValueSet);
user2250152
  • 14,658
  • 4
  • 33
  • 57