7

What is the proper JSON syntax to update a multi-choice list item field using the Microsoft Graph?

Multi choice fields return a json array of strings like:

GET: /v1.0/sites/{siteId}/lists/{listId}/items/{itemId}

"CAG_x0020_Process_x0020_Status": [
    "Proposed Funding - Customer Billed",
    "Proposed Funding - Sales Funded",
    "SOW - Needed"
]

However, when using the same syntax to update the field a 400 invalid request is returned.

PATCH: /v1.0/sites/{siteId}/lists/{listId}/items/{itemId}/fields

"CAG_x0020_Process_x0020_Status": [
    "Proposed Funding - Customer Billed",
    "Proposed Funding - Sales Funded",
    "SOW - Needed"
]

Error returned:

{
  "error": {
    "code": "invalidRequest",
    "message": "The request is malformed or incorrect.",
    "innerError": {
      "request-id": "2251e25f-e4ce-491f-beb9-e463c7d8d5af",
      "date": "2018-05-16T15:16:23"
    }
  }
}

I am able to update all other fields requested, but this last field is holding up a release of the application.

Marc LaFleur
  • 31,987
  • 4
  • 37
  • 63

3 Answers3

5

To elaborate on what @muhammad-obaidullah-ather wrote in the comments, for string multiple choices you need to define the type as Collection(Edm.String) and then his solutions works for me. Repeating what he wrote as complete answer. This should be sent as a PATCH like this:

PATCH /v1.0/sites/{SiteId}/lists/{ListId}/items/{ItemId}/fields

{"*FieldName*@odata.type":"Collection(Edm.String)","*FieldName*":["*Value1*","*Value2*"]}
Arghya Sadhu
  • 41,002
  • 9
  • 78
  • 107
Ken Bragg
  • 101
  • 1
  • 4
3

This works for me

graph.api(url)
  .version('beta')
  .post({
    'fields': {
      'AssignedToLookupId@odata.type': 'Collection(Edm.Int32)',
      'AssignedToLookupId': [5,13]
    }
  });
A. Mechai
  • 31
  • 4
0

Unfortunately, a number of column types, including MultiChoice, cannot be updated via Microsoft Graph today. I would recommend adding this to the Office Dev UserVoice so it remains on the radar of the SharePoint/Graph team.

Marc LaFleur
  • 31,987
  • 4
  • 37
  • 63
  • 1
    its supported. you can do it like graph.api(url) .version('beta') .post({ 'fields': { "CAG_x0020_Process_x0020_Status@odata.type": "Collection(Edm.String)", "CAG_x0020_Process_x0020_Status": [ "Proposed Funding - Customer Billed", "Proposed Funding - Sales Funded", "SOW - Needed" ] } }); – Muhammad Obaidullah Ather Mar 14 '20 at 11:09