google-api - 如何使用gmail的批处理api来列出gmail?

标签 google-api gmail-api batch-request

想要对列表进行批量请求,该列表可以在 gmail api 中附带每条消息的发件人和标题。我怎样才能批量请求它?是否可以使用 postman 发出批量请求?

作为批量请求的一部分,如何请求批量请求?

如何对上述要求端点使用批量请求?

As part of batch request as per google doc ,
POST /batch/farm/v1 HTTP/1.1
Authorization: Bearer your_auth_token
Host: www.googleapis.com
Content-Type: multipart/mixed; boundary=batch_foobarbaz
Content-Length: total_content_length

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

GET /farm/v1/animals/pony

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

PUT /farm/v1/animals/sheep
Content-Type: application/json
Content-Length: part_content_length
If-Match: "etag/sheep"

{
  "animalName": "sheep",
  "animalAge": "5"
  "peltColor": "green",
}

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

GET /farm/v1/animals
If-None-Match: "etag/animals"

--batch_foobarbaz--

根据我的要求,我不明白如何修改文档请求?

最佳答案

How can I make a batch request for it?

通过使用批处理端点 Batching

Is it possible to make a batch request using postman?

是的, postman 可以处理这个电话。但是您必须手动创建正文,考虑到可以包含 100 个请求,这将非常耗时,并且在我看来很容易出错。

As part of batch request, how batch request can be requested ?

通过发送 HTTP Post,其中正文包含您请求数据的每个单个请求。

how can I use batch request for above requirement endpoints?

您可以使用 postman 或任何其他可以处理 http post 调用的编程语言来完成此操作。

正文中的每一行 GET/farm/v1/animals 都包含您希望向 api 发出的请求,在您的情况下,它会类似于 users/me/messages/1.

您需要首先调用用户 messages.list 获取您想要获取其信息的所有消息 ID 的列表。然后构建对 user.messages 的批量请求以获取和请求每条消息。批处理并不意味着您不需要为每个消息发送 get 请求,批处理只是为您节省了通过发送每个 get 请求而进行的额外 http 调用。

POST /batch/gmail/v1 HTTP/1.1
Authorization: Bearer your_auth_token
Host: www.googleapis.com
Content-Type: multipart/mixed; boundary=batch_foobarbaz
Content-Length: total_content_length
Accept-Encoding: application/gzip

--batch_foobarbaz
Content-Type: application/http


GET gmail/v1/users/me/messages/16d24956228a98c4
Accept: application/json; charset=UTF-8

--batch_foobarbaz
Content-Type: application/http


GET gmail/v1/users/me/messages/16d24956228a98c4
Accept: application/json; charset=UTF-8

--batch_foobarbaz--

关于google-api - 如何使用gmail的批处理api来列出gmail?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57899811/

相关文章:

rest - 使用 POSTMAN 或任何其他方式批量 POST/PUT API 请求

java - 使用Java中的批处理请求和nextPageToken从Google Drive Api获取超过1000个文件

javascript - Uncaught ReferenceError : variableis not defined

google-api - 无法通过服务帐户访问 Google Calendar API

powershell - 使用 Gmail API 在 Powershell 中使用 Invoke-WebRequest 发送电子邮件

gmail-api 下载附件,base64 编码错误

php - 如何在 PHP 中生成 SHA256withRSA?我怎么知道官方示例中的 [签名字节] 是什么?

android - 使用 GMAIL AutoForwarding 创建时权限不足

python - Gmail 应用程序 - 快速入门,错误 : redirect_uri_mismatch