停止Google推送通知,回复“找不到项目的渠道" [英] Stop Google push notification, response "channel not found for project"
问题描述
我正在使用Google Calendar Push Notifications.一切正常,我注册我的频道没有任何问题.日历的更改将按预期方式发出通知.
I am using Google Calendar Push Notifications. All is working well and I register my channel with no issue. Changes to the calendar result in a notification as expected.
我想停止推送通知.我正在呼叫Google停止推送通知API.
" https://www.googleapis.com/calendar/v3/channels/stop
但是我收到错误代码:404 and message: "Channel not found for project"
.
I want to stop the push notification. I am calling Google stop push notification API.
"https://www.googleapis.com/calendar/v3/channels/stop"
But I am getting Error code: 404 and message: "Channel not found for project"
.
请求:
googleCalendar.channels.stop({
auth: oauth2Client,
resource: {
id: 'cfabcfaa-a6eb-4432-8068-6417ee2ce8a6', //channelID
resourceId: '3kGwQdmzSMCZ41MAFdwEzt0ugNQ' //resourceID
}
}, function(err, results) {
if(err){
return;
}
console.log(results) })
响应:
{ [Error: Channel 'cfabcfaa-a6eb-4432-8068-6417ee2ce8a6' not found for project '87165627894']
code: 404,
errors:
[ { domain: 'global',
reason: 'notFound',
message: 'Channel \'cfabcfaa-a6eb-4432-8068-6417ee2ce8a6\' not found for project \'87165627894\'' } ] }
有人可以帮助我为什么我遇到此错误吗? 谢谢.
Can anyone help me why I am getting this error? Thanks.
推荐答案
我无法确认您是否正在使用库,但似乎您正在调用频道停止方法(用于停止推送通知).
I can't confirm if you're using a library, but it seems that you're calling the calendarList watch method and not the channel stop method (which is used to stop push notification).
基于推送通知 Calendar API文档中的>页面,必填字段实际上是channelID和resourceID(如您所指定的;还需要用户的auth令牌)
Based on the Push Notification page in the Calendar API documentation, the required fields are indeed channelID and resourceID (as what you've specified; also required is the auth token of the user)
https://www.googleapis.com/calendar/v3/channels/stop
POST https://www.googleapis.com/calendar/v3/channels/stop
Authorization: Bearer {auth_token_for_current_user}
Content-Type: application/json
{
"id": "4ba78bf0-6a47-11e2-bcfd-0800200c9a66",
"resourceId": "ret08u3rv24htgh289g"
}
这篇关于停止Google推送通知,回复“找不到项目的渠道"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!