What's the POST body to create multichoice fields in sharepoint online using graph api?

天大地大妈咪最大 提交于 2019-12-11 17:48:29

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!