Microsoft Graph 更新 SharePoint 列表项多选字段字段、多选、列表、Microsoft

2023-09-06 17:35:10 作者:塞外的短暂

使用 Microsoft Graph 更新多选列表项字段的正确 JSON 语法是什么?

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

多选字段返回一个 json 字符串数组,例如:

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

但是,当使用相同的语法更新字段时,会返回 400 无效请求.

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

补丁:/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": {
    "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.

推荐答案

这对我有用

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