【问题标题】:Gmail api returns 404 error when calling message.getGmail api 在调用 message.get 时返回 404 错误
【发布时间】:2017-06-25 05:03:48
【问题描述】:

Gmail API history.list 正在返回 messageId,当 message.get 被调用时返回 404。

我用“INBOX”标签和“history/messagesAdded”字段调用history.list。然后我调用 message.get 并返回每个 messageId。其中一些返回有效消息,另一些返回以下异常:

Google_Service_Exception
{
   "error": {
   "errors": [
   {
     "domain": "global",
     "reason": "notFound",
     "message": "Not Found"
    }
   ],
  "code": 404,
  "message": "Not Found"
 }
}

这是什么原因造成的?似乎我们只是检索了 messageId,没有足够的时间将它们现在永久删除。

【问题讨论】:

  • 如果您还获得了history/messagesDeletedhistory/labelsRemoved 字段,您可能会看到这些消息已被删除。
  • 它们会同时出现在history/messagesAddedhistory/messagesDeleted 中进行同一个调用吗?
  • 是的。您将获得从historyId 到现在为止的历史记录,因此如果该邮件已添加到收件箱并从historyId 删除,则相同的messageId 将同时出现在history/messagesAddedhistory/messagesDeleted 中。

标签: gmail-api


【解决方案1】:

如 cmets 中所述,如果消息被删除,就会发生这种情况。这可以在 gmail's history.list 返回的 messagesDeleted 数组中进行检查,只需确保发送适当的 historyTypes(或根本不发送任何内容)。

{
 "history": [
  {
   "id": "69014",
   "messagesAdded": [
    {
     "message": {
      "id": "165a2cd1a5b308b9",
      "threadId": "1659e85b88e80e7b",
     }
    }
   ]
  },
  {
   "id": "69024",
   "messagesDeleted": [
    {
     "message": {
      "id": "165a2cd1a5b308b9",
      "threadId": "1659e85b88e80e7b",
     }
    }
   ]
  }
}

【讨论】:

    猜你喜欢
    • 2016-04-04
    • 2022-11-15
    • 1970-01-01
    • 2017-01-14
    • 1970-01-01
    • 1970-01-01
    • 2023-03-23
    • 2021-08-12
    • 2020-10-27
    相关资源
    最近更新 更多