问题
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?
回答1:
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": {
"choice_checkboxes@odata.type": "Collection(Edm.String)",
"choice_checkboxes":["cb1","cb2"]
}
}
回答2:
Thanks @Brad, it worked for me. I able to post lookup column values using following
"ProductsLookupId@odata.type": "Collection(Edm.Int32)",
"ProductsLookupId":[6,7,8]
Where Products is a lookup column to allow multiple choice.
来源:https://stackoverflow.com/questions/49238355/whats-the-post-body-to-create-multichoice-fields-in-sharepoint-online-using-gra