You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用MS Graph API更新事件返回HTTP 400错误求助

问题描述

在Pega 8.6.4中调用MS Graph API的PATCH请求更新会议事件(修改起止时间、参会人员、地点)时,持续收到HTTP 400 Bad Request错误,但应用能正常创建和取消事件,请求详情如下:

请求数据

{
  "subject": "X",
  "start": {
    "timeZone": "W. Europe Standard Time",
    "DateTime2": "20220727T103000.000 GMT"
  },
  "end": {
    "timeZone": "W. Europe Standard Time",
    "DateTime2": "20220727T113000.000 GMT"
  },
  "location": {
    "uniqueIdType": "private",
    "displayName": "X",
    "locationType": "default",
    "uniqueId": "X"
  },
  "body": {
    "contentType": "html",
    "content": "<html> 	<body> 		<p>Afspraak met: X</p> 		<p>X ANTWERPEN </p> 		<p>E-mailadres: X</p> 		<p>Telefoonummer: X</p> 		<p>Klantnummer: 45</p> </body> </html> "
  }
}

请求信息

  • 请求方法:PATCH
  • 请求URL:https://graph.microsoft.com/v1.0/users/{userprincipalname}/events/{EventID}
  • 请求头:Content-Type = "application/json"

错误原因及修复方案

1. 日期字段名错误

MS Graph API中,事件起止时间的字段名应为**dateTime**(小写驼峰格式),而非请求中的DateTime2,字段名不匹配会直接触发400校验错误。

2. 日期格式不规范

请求中的日期格式20220727T103000.000 GMT不符合ISO 8601标准,正确格式应为:

  • UTC时间:2022-07-27T10:30:00Z
  • 带时区偏移的本地时间:2022-07-27T10:30:00+02:00(对应西欧夏令时)
    无需添加GMT后缀。

3. Location参数冗余

当locationType设为default时,uniqueIdType和uniqueId属于非必填冗余参数,可能因参数合法性校验失败导致错误,建议移除。


修复后的请求示例
{
  "subject": "X",
  "start": {
    "timeZone": "W. Europe Standard Time",
    "dateTime": "2022-07-27T10:30:00"
  },
  "end": {
    "timeZone": "W. Europe Standard Time",
    "dateTime": "2022-07-27T11:30:00"
  },
  "location": {
    "displayName": "X",
    "locationType": "default"
  },
  "body": {
    "contentType": "html",
    "content": "<html> 	<body> 		<p>Afspraak met: X</p> 		<p>X ANTWERPEN </p> 		<p>E-mailadres: X</p> 		<p>Telefoonummer: X</p> 		<p>Klantnummer: 45</p> </body> </html> "
  }
}

额外注意事项
  • 若需更新参会人员,需保证attendees数组中每个对象包含emailAddress(含name和address字段)和type(可选值:required/optional/resource)参数,格式需严格符合API规范。
  • 确认请求中的EventID为有效事件ID,无拼写或格式错误。
  • 检查应用权限(如Calendars.ReadWrite),虽然创建/取消事件正常,但权限问题一般返回403而非400,优先级较低。

内容的提问来源于stack exchange,提问作者Alyssa Capco

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.25 00:39:17