【问题标题】:Gmail API returning non-existent threadsGmail API 返回不存在的线程
【发布时间】:2015-09-26 20:22:57
【问题描述】:

我正在使用 gmail API 列出线程,但我发现使用 users_threads->get 无法找到从 users_threads->list 返回的某些项目。这些项目也无法通过 gmail 的 Web UI 看到。

我正在使用 gmail 的 api explorer (https://developers.google.com/gmail/api/v1/reference/users/threads/list) 来测试列表线程。

我的收件箱对于经过身份验证的帐户是空的。

站点发出类似GET https://www.googleapis.com/gmail/v1/users/me/threads?labelIds=INBOX&key={YOUR_API_KEY} 的请求并返回此结果集:

200 OK

cache-control:  no-cache, no-store, max-age=0, must-revalidate
content-encoding:  gzip
content-length:  287
content-type:  application/json; charset=UTF-8
date:  Wed, 08 Jul 2015 18:23:25 GMT
etag:  "A_TI-e9NgLq0wln5q88xm3zdvSg/6meEdFVG8voZD7dqGr76UTURSRk"
expires:  Fri, 01 Jan 1990 00:00:00 GMT
pragma:  no-cache
server:  GSE
vary:  Origin, X-Origin
{
 "threads": [
  {
   "id": "14a78517c954ec9c",
   "snippet": "",
   "historyId": "806722"
  },
  {
   "id": "149daea953d5674e",
   "snippet": "",
   "historyId": "688170"
  },
  {
   "id": "149d462f26b543db",
   "snippet": "",
   "historyId": "686319"
  },
  {
   "id": "149ac0958a5b44e8",
   "snippet": "",
   "historyId": "657008"
  },
  {
   "id": "149ac0c2caea09f7",
   "snippet": "",
   "historyId": "656272"
  },
  {
   "id": "149ac08d36ce3087",
   "snippet": "",
   "historyId": "656263"
  },
  {
   "id": "148e3ab2c048f49e",
   "snippet": "",
   "historyId": "491569"
  },
  {
   "id": "147a123d780d44a7",
   "snippet": "",
   "historyId": "186314"
  },
  {
   "id": "1478f8b6c004dddb",
   "snippet": "",
   "historyId": "178535"
  },
  {
   "id": "1478cf683ca0dc8d",
   "snippet": "",
   "historyId": "177603"
  },
  {
   "id": "14788aa2aba1f35a",
   "snippet": "",
   "historyId": "173433"
  }
 ],
 "resultSizeEstimate": 11
}

当我期望0 时,它似乎返回11 对象。

此外,如果我对这些项目中的任何一个使用 threads->get api (https://developers.google.com/gmail/api/v1/reference/users/threads/get),我会收到以下响应:

GET https://www.googleapis.com/gmail/v1/users/me/threads/1478cf683ca0dc8d?key={YOUR_API_KEY}

404 Not Found

cache-control:  private, max-age=0
content-encoding:  gzip
content-length:  120
content-type:  application/json; charset=UTF-8
date:  Wed, 08 Jul 2015 18:30:21 GMT
expires:  Wed, 08 Jul 2015 18:30:21 GMT
server:  GSE
vary:  Origin, X-Origin
{
 "error": {
  "errors": [
   {
    "domain": "global",
    "reason": "notFound",
    "message": "Not Found"
   }
  ],
  "code": 404,
  "message": "Not Found"
 }
}

API 中似乎存在错误。根据support page,我应该使用gmail-api 标记将所有关注点转移到stackoverflow,我已经这样做了。

如果 stackoverflow 上的共识是这是一个产品错误,我会submit an issue with the product team,因为我还没有找到任何类似的错误提交。

感谢您为解决此问题提供的任何帮助。

【问题讨论】:

    标签: gmail-api


    【解决方案1】:

    这不是 API 中的错误。 threads.list() 将返回所有电子邮件线程,包括已删除的电子邮件线程。您必须在已删除的消息上收到 404。如果消息已被永久删除,它仍会显示在 threads.list() 调用中,并且 message.get() 调用将在此类消息上失败。

    希望这能净化一些空气。

    【讨论】:

    • 有趣...为什么有人希望列出已删除的线程?有没有办法从我的列表中删除这些?
    • @johncorser 尝试使用 message.list() 和 message.get() 或者 history.list() 以及响应对象的“messagesAdded”部分。
    • threads.list() 不应返回已删除的线程。这似乎是一个错误。
    猜你喜欢
    • 2018-11-20
    • 1970-01-01
    • 2020-07-21
    • 2019-04-12
    • 1970-01-01
    • 2020-04-27
    • 2023-03-30
    • 2021-04-17
    • 2019-07-10
    相关资源
    最近更新 更多