google-calendar-api - Google 日历 API 批量插入已停止工作

标签 google-calendar-api

我有一个应用程序,已成功使用 HTTP 批量请求通过 Google Calendar API 插入、编辑和删除事件。在过去几天中,批处理中的各个请求已开始返回 404 错误(尽管批处理本身获得 200 成功响应)。使用相同的授权 header 将这些相同的请求作为单独的请求仍然有效。

我很确定这与 forthcoming shutdown of Google's global HTTP batch endpoints 无关因为我们正在使用https://www.googleapis.com/batch/calendar/v3作为我们的端点。

这是我正在尝试做的事情的示例:

https://www.googleapis.com/batch/calendar/v3
Authorization: Bearer your_auth_token
Content-Type: multipart/mixed; boundary=batch_google_calendar

--batch_google_calendar
Content-Type: application/http
Content-ID: <<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="f69f82939bdbc6db949782959e9380939882b6938e979b869a93d895999b" rel="noreferrer noopener nofollow">[email protected]</a>>

POST calendar/v3/calendars/<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="067f6973745965676a6368626774596f624661746973762865676a636862677428616969616a632865696b" rel="noreferrer noopener nofollow">[email protected]</a>/events
Content-Type: application/json

{"summary":"batch API test","start":{"date":"2020-07-31"},"end":{"date":"2020-07-31"}}
--batch_google_calendar--

响应是:

--batch_3J6sfuPtVQbjZLcpUe06245gKlO31YnC
Content-Type: application/http
Content-ID: <<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="f5879086859a9b8690d89c819098d8c5d8979481969d9083909b81b5908d9498859990db969a98" rel="noreferrer noopener nofollow">[email protected]</a>>

HTTP/1.1 404 Not Found
Vary: Origin
Vary: X-Origin
Vary: Referer
Content-Type: application/json; charset=UTF-8

[{
  "error": {
    "code": 404,
    "message": "URL path: /v3/calendars/<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="7a03150f0825191b161f141e1b0825131e3a1d08150f0a54191b161f141e1b08541d15151d161f54191517" rel="noreferrer noopener nofollow">[email protected]</a>/events could not be resolved. Maybe there is an error parsing the batch item.",
    "status": "NOT_FOUND"
  }
}
]
--batch_3J6sfuPtVQbjZLcpUe06245gKlO31YnC--

以下是有效的单个请求的示例:

https://www.googleapis.com/calendar/v3/calendars/<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="b4cddbc1c6ebd7d5d8d1dad0d5c6ebddd0f4d3c6dbc1c49ad7d5d8d1dad0d5c69ad3dbdbd3d8d19ad7dbd9" rel="noreferrer noopener nofollow">[email protected]</a>/events
Authorization: Bearer your_auth_token
Content-Type: application/json

{"summary":"API test","start":{"date":"2020-07-31"},"end":{"date":"2020-07-31"}}

为什么单个请求会成功但批量请求会失败?

最佳答案

Google 通过他们的问题跟踪器给出了有用的答复:我的应用程序中特定的批处理条目路径的方式存在错误。直到上周,这一切都没有错误,所以我认为最终一定发生了一些变化,以使其对错误的容忍度降低。

我们犯的错误是在每个批处理条目的路径中省略了前导斜杠。这就是我们正在做的事情:

POST calendar/v3/calendars/<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="d9a0b6acab86bab8b5bcb7bdb8ab86b0bd99beabb6aca9f7bab8b5bcb7bdb8abf7beb6b6beb5bcf7bab6b4" rel="noreferrer noopener nofollow">[email protected]</a>/events

这就是我们应该做的事情:

POST /calendar/v3/calendars/<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="30495f45426f53515c555e5451426f59547057425f45401e53515c555e5451421e575f5f575c551e535f5d" rel="noreferrer noopener nofollow">[email protected]</a>/events

我希望这对遇到类似情况的其他人有所帮助!

关于google-calendar-api - Google 日历 API 批量插入已停止工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63177993/

相关文章:

android - 在 Eclipse Android Java 中编程谷歌日历 API

ruby-on-rails - Google 日历与初始 time_max 增量同步

google-api - 如何建立指向谷歌日历事件的 html 链接?

google-calendar-api - Google 日历 ICS 文件多事件导入不起作用

Javascript Google Calendar API 将日历设置为公开

ios - 通过API在Google日历上创建重复事件

ios - Google 登录显示不正确的项目名称 - iOS

events - 在 GAS 触发事件代码中,如何找出更新了哪个 Google 日历事件?

python - 在插入事件之前插入新日历 Google API 和删除日历事件(Python 中)

calendar - 创建 "Add to Google Calendar"链接需要哪些参数?