Gmail API返回不存在的线程

时间:2015-07-08 18:33:10

标签: gmail-api

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

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

我的收件箱为auth'd帐户为空。

网站发出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
}

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

此外,如果我对任何这些项目使用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中似乎存在错误。根据{{​​3}}我应该使用gmail-api标记将所有关注点引导到stackoverflow,我已经完成了。

如果stackoverflow的共识是这是一个产品错误,我会support page因为我找不到任何类似的错误。

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

1 个答案:

答案 0 :(得分:5)

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

希望这能清除一些空气。