6

如何通过 V3 REST API 使用批处理请求获取/添加/更新 Google 日历事件?我试过了,但没有用。根据文档(https://developers.google.com/google-apps/calendar/batch),应该可以通过向 API 发布多部分/混合内容类型消息来发送批处理请求。一个有效的 HTTP POST 的例子会很棒。

谢谢, 里亚兹

4

3 回答 3

1

The following batch request, gets the eventId1, updates the eventId2 and creates a new event under calender that is identified with calendarId.

POST /batch HTTP/1.1
Authorization: /*Auth token*/
Host: host
Content-Type: multipart/mixed; boundary=batch_foobarbaz
Content-Length: total_content_length

--batch_foobarbaz
Content-Type: application/http
Content-ID: <item1:x@barnyard.example.com>

GET /calendar/v3/calendars/calendarId/events/eventId1

--batch_foobarbaz
Content-Type: application/http
Content-ID: <item2:x@barnyard.example.com>

PUT /calendar/v3/calendars/calendarId/events/eventId2
Content-Type: application/json
Content-Length: part_content_length

{{ body }}

--batch_foobarbaz
Content-Type: application/http
Content-ID: <item3:x@barnyard.example.com>

POST /calendar/v3/calendars/calendarId/events
Content-Type: application/json
Content-Length: part_content_length

{{ body }}

--batch_foobarbaz--
于 2013-07-11T14:50:48.650 回答
1

我发现外部 URL 必须是“https://www.googleapis.com/batch/calendar/v3/” ,边界 url 必须是“/calendar/v3/calendars/{calendarID}/events”

完整的 HTTP 请求如下所示:

POST /batch/calendar/v3 HTTP/1.1
Authorization: /*Auth token*/
Host: host
Content-Type: multipart/mixed; boundary=batch_foobarbaz
Content-Length: total_content_length

--batch_foobarbaz
Content-ID: 1

GET /calendar/v3/calendars/{calendarID1}/events

--batch_foobarbaz
Content-ID: 2

GET /calendar/v3/calendars/{calendarID2}/events

--batch_foobarbaz--
于 2021-07-19T19:40:48.423 回答
0

端点是

https://www.googleapis.com/batch

当我执行日历批处理请求时,这对我有用。我遇到的一个问题是我的最后一个边界令牌我没有--它之后。因此,每个令牌都以开头,--最后一个令牌--以结尾。正如@Burcu Dogan 的示例所示。

于 2014-10-21T23:09:13.417 回答