Nathan Yorke
Nathan Yorke

Reputation: 81

Microsoft Graph update SharePoint list item multi choice field

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.

Upvotes: 8

Views: 3640

Answers (3)

Ken Bragg
Ken Bragg

Reputation: 131

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*"]}

Upvotes: 7

A. Mechai
A. Mechai

Reputation: 31

This works for me

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

Upvotes: 3

Marc LaFleur
Marc LaFleur

Reputation: 33122

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.

Upvotes: 0

Related Questions