Gmail API ID 无效,但线程 ID 有效

Gmail API ID is not working but and thread ID is working

当我查询 Gmail 时 API

results = service.users().messages().list(userId='me',q="from:xyz@wso2.com", maxResults=10).execute()

我得到了这个输出。在这里我没有收到每条消息它只返回了 Thread Idid

"messages": [
  {
   "id": "1655b9b497dc76aa",
   "threadId": "165380da74833127"
  },
  {
   "id": "1655b9a7409383dd",
   "threadId": "1655b9a7409383dd"
  },
  {
   "id": "1655b9a25c441268",
   "threadId": "16470b77316be7ab"
  },
  {....

为了得到消息,我不得不再次查询。这里的问题是当我使用 Id 查询时它返回 400 错误但是当我使用线程时它返回带有片段的消息。但是在documentation中,他们已经明确提到我们必须给id

id -    string  - The ID of the message to retrieve.
  1. Thread Id 和 Id 有什么区别?
  2. 我不能查询所有字段吗-

"labelIds": [ "UNREAD", "CATEGORY_FORUMS", "INBOX" ], "snippet": "Hi Amanda, Ruwan and Mifan, We've got through to the RFP round with Verizon! Could you please review the RFP and start working on this? Let me know if we need to get WSO2 Telco involved. Thanks,", "historyId": "5217959", "internalDate": "1534833021000"....

作为 JSON 而不是一次又一次地使用每个 Id 进行查询?似乎 Google API 可能会阻止我使用节流机制 如果我查询那么多时间因为我必须查询 150000 个 ID。

来自文档Message resource,其中为响应中的每条消息返回一个。

id string The immutable ID of the message.

threadId string The ID of the thread the message belongs to. To add a message or draft to a thread, the following criteria must be met:

  • The requested threadId must be specified on the Message or Draft.Message you supply with your request.
  • The References and In-Reply-To headers must be set in compliance with the RFC 2822 standard. -The Subject headers must match.

你不能在 message.threadid 上做 message.get message.get 需要 message.id

Can't I query all the messages as a JSON without querying, again and again, using every Id? It seems Google API may block me using throttling mechanism If I query that much of time since I have to query 150000 ids.

不,可以返回的 maxResults 没有限制。我认为它大约有 100 个,但我没有看到它被记录下来。您将不得不使用请求中返回的 nextPageToken 来获取下一页结果。您提出请求的速度是有限制的。所以保持合理,否则你会被扼杀。

更新以回复问题编辑

Can't I query all the fields-

如果您运行以下使用fields=*Doc on fields paramater

results = service.users().messages().list(userId='me',q="from:xyz@wso2.com", maxResults=10,fields=*).execute()

您会注意到响应是一样的

   {
   "id": "1655bb6d0f2b5f8f",
   "threadId": "1655bb6d0f2b5f8f"
    },

这是一个files.list的响应中的所有字段。如果您想了解更多信息,您必须执行 message.get

Gmail 配额

因此,Gmail 的配额很大。其中大部分还可以扩展。