0

I would like to update the value of a "choice column" but when I call the UpdateAsync method it throws an exception with the following message "Code: invalidRequest - Message: Invalid request".

In previous versions of Sharepoint, the values of the choice columns were separated by ";#" characters, but with Microsoft Graph and Sharepoint Online it seems that this requirement has changed to an array of values. At least I think so...

Any ideas on how to solve this problem?

I am using the following code:

var fieldValueSet = new FieldValueSet
{
    AdditionalData = new Dictionary<string, object>()
    {
        {"Field1", "Test1"},
        { "Field2", ["Test2-A", "Test2-B", "Test3-C"]}
    }
};    
await graphClient
    .Sites["{site-id}"]]
    .Lists["{list-id}"]]
    .Items["{listItem-id}"]
    .Fields
    .Request()
    .UpdateAsync(fieldValueSet);```
Rubén
  • 29
  • 2
  • 6

1 Answers1

0

You need to add a field to specify that the value for Field2 is an array of strings. Collection(Edm.String).

Also send the array of values in string "[\"Test2-A\",\"Test2-B\",\"Test3-C\"]"

var fieldValueSet = new FieldValueSet
{
    AdditionalData = new Dictionary<string, object>()
    {
        {"Field1", "Test1"},
        {"Field2@odata.type", "Collection(Edm.String)"},
        {"Field2", "[\"Test2-A\",\"Test2-B\",\"Test3-C\"]"}
    }
};
user2250152
  • 14,658
  • 4
  • 33
  • 57