404“更改未找到”推送通知API的消息并获取更改API [英] 404 "Change not found" message of push notification API and get changes API

查看:152
本文介绍了404“更改未找到”推送通知API的消息并获取更改API的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个关于推送通知API的问题。



我在我的服务下创建了web_hook URL来推送通知,所以我可以通过URL获取文档更改状态selfLink。



但我在使用selfLink获取URL时有时会得到404代码。



请让我知道为什么Drive API响应404代码有时。




场景:

请求来自Google推送通知服务器的正文

  {
kind:drive#changes,
id:12345,
selfLink:https://www.googleapis.com/drive/v2/changes/12345
}

在我的服务器下抓取网址。

  GET https://www.googleapis。 com / drive / v2 / changes / 12345 

响应正文

  {
error:{
errors:[
{
domain:global,,
reason:notFound,
message:未找到更改:12345
}
],
code:404,
message:Change not found:12345
}
}


解决方案

对文件进行的更改是invalida通过对文件进行后续更改。



假设您已更改#100,并为其获取推送通知。在更改发送给您之后,可以说对文件进行了另一次编辑,更改戳记为101.现在,更改戳记101将使更改戳记100无效。



一个处理这个问题的方法可能是获取更改> =您获得的更改编号,并通过fileId进行过滤。



还要注意打开文件,即使您不不做任何编辑,更新它的lastViewed时间,从而生成新的更改,从而使较旧的更改戳无效。


I have a question about push notification API.

I've created web_hook URL under my service for push notification, so I can fetch URL for document change status with selfLink.

But I get 404 codes sometimes when I fetch URL with selfLink.

Please let me know why Drive API response 404 code sometimes.

Scenario:

Request body from google push notification server.

{
  "kind": "drive#changes",
  "id": "12345",
  "selfLink": "https://www.googleapis.com/drive/v2/changes/12345"
}

Fetch URL under my server.

GET https://www.googleapis.com/drive/v2/changes/12345 

Response body

{
 "error": {
  "errors": [
   {
    "domain": "global",
    "reason": "notFound",
    "message": "Change not found: 12345"
   }
  ],
  "code": 404,
  "message": "Change not found: 12345"
 }
} 

解决方案

A change made to a file is invalidated by a subsequent change to the file.

Lets say you have change #100, and get a push notification for it. Between the time the change was sent to you, lets say another edit was made to the file, with a changestamp of 101. Now changestamp 101 will invalidate changestamp 100.

One way to deal with this might be to get changes >= the change number that you get, and filter by fileId.

Also of note opening a file, even if you don't make any edits, updates it's lastViewed time, and thus generates a new change, thereby invalidating the older changestamp.

这篇关于404“更改未找到”推送通知API的消息并获取更改API的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆