3
votes

I'm trying to create new SharePoint ListItem using Microsoft Graph.

To create a list item with simple fields like Title, my POST body looks like:

{
   "fields":{
       "Title":"Ehsan's REST"
   }
}

But as soon as I add a field with the multichoice value I get The request is malformed or incorrect. error.

example:

{
   "fields":{
       "Title":"Ehsan's REST",
       "Languages": ["English","French"]
   }
}

During my search I found this forum post where SharePoint API (not Graph ) requires a metadata attribute to be added to the collection as an object:

"InternalFieldName":{
  "__metadata":{"type":"Collection(Edm.String)"},
  "results":["Value1","Value2","Value3"]
}

There's an open issue on microsoft graph doc github related to this as well.

Any suggestions?

2
So we gave up on using Microsoft Graph API for SharePoint to insert or edit list items as there’s not much of support by its community. Switching to direct SharePoint API calls.Ehsan Mahpour
At this time, it looks as if choice list items are unable to be created by the Microsoft Graph API: stackoverflow.com/questions/50374762/… Here's an open Feature Request Linkrothkinder

2 Answers

3
votes

You should be able to set the value of multi-choice columns, but you'd have to specify the type of the field to make sure OData understands it:

{
  "fields": {
    "[email protected]": "Collection(Edm.String)",
    "choice_checkboxes":["cb1","cb2"]
  }
}
2
votes

I am able to post lookup column values using following:

"[email protected]": "Collection(Edm.Int32)",
"ProductsLookupId":[6,7,8]

Where Products is a lookup column to allow multiple choice.