Create ListItem with Choice Column

Shadi Rashed 71 Reputation points
2022-04-15T10:10:28.02+00:00

Hello,
I am trying to create a new ListItem. The list has only two columns (Title and ProductCategory1). The column is a choice column that allows multiple selection. The possible values are "Value 1", "Value 2" and "Value 3"

Here is what I tried
POST https://graph.microsoft.com/v1.0/sites/siteid/lists/listid/items/

Body:
{ "fields": { "Title": "Test", "ProductCategory1": ["PWR/Electronics","BIW/Exteriors"] } }

returns a 400 error without further description

{ "fields": { "Title": "Test", "ProductCategory1": {"choices": ["PWR/Electronics","BIW/Exteriors"]} } }

returns a 400 error without further description.
How do I fill this choice field when I create the ListItem? There absolutely no examples anywhere in the documentation for more complex types than string fields.

Thanks for your help!
Shadi

Microsoft 365 and Office SharePoint Development
Microsoft Security Microsoft Graph
0 comments No comments
{count} votes

Accepted answer
  1. Rob Windsor 2,001 Reputation points
    2022-04-15T12:00:02.99+00:00

    You need to add a field to tell Microsoft Graph that the value for ProductCategory1 is an array of strings.

    {
        "fields": {
            "Title": "Test",
            "******@odata.type": "Collection(Edm.String)",
            "ProductCategory1": [
                "PWR/Electronics",
                "BIW/Exteriors"
            ]
        }
    }
    
    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.