google-api-nodejs-client: Cannot stop watching a channel
googleapi version: 12.4.0 api version: 3
Steps to reproduce
-
Start watching a drive file
drive.files.watch({ fileId, resource: { id: 'my-chanel', type: 'web_hook', address: 'https://example.com/api/gsheets' } }, (err, result) => { ... });
It works good, I get info about channel and start receiving notfnications about changes.
-
Try to stop channel
drive.channels.stop({ resource: { id: 'my-channel', resourceId: 'given resource id goes here' } }, (err, result) => { ... });
Expected result
Some message about successful operation
Actual result
error: Error: Channel 'my-channel' not found for project '636397034666'
at Request._callback (/Users/jifeon/projects/plyo.web/node_modules/google-auth-library/lib/transporters.js:82:15)
at Request.self.callback (/Users/jifeon/projects/plyo.web/node_modules/google-auth-library/node_modules/request/request.js:198:22)
at emitTwo (events.js:100:13)
at Request.emit (events.js:185:7)
at Request.<anonymous> (/Users/jifeon/projects/plyo.web/node_modules/google-auth-library/node_modules/request/request.js:1057:14)
at emitOne (events.js:95:20)
at Request.emit (events.js:182:7)
at IncomingMessage.<anonymous> (/Users/jifeon/projects/plyo.web/node_modules/google-auth-library/node_modules/request/request.js:1003:12)
at emitNone (events.js:85:20)
at IncomingMessage.emit (events.js:179:7)
at endReadableNT (_stream_readable.js:913:12)
at _combinedTickCallback (node.js:377:13)
at process._tickDomainCallback (node.js:425:11)
and if I try to watch again, it says “Channel id is not unique”
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Comments: 22 (4 by maintainers)
Also, it’s a little weird to not be able to stop channels with the params you used to create them - if you somehow forget to extract the resourceId from the response are you just stuck getting events until you hit the expiration time?
Was getting the useless “Required” error above too. I had forgotten to put the “id” and “resourceId” inside a “resource” object. This structure is very poorly documented:
var params = { "auth": { }, "resource": { "id": "...", "resourceId": "..." } }
The fact that you need the
resourceId
(which seems to be only returned in the watch request response) to stop events for a particular channel makes channels/events harder to work with.So to be more precise here, I supplied an ID of a spreadsheet to the watch function, which the service turned into of an ID of the file representing the spreadsheet. So the above documentation is OK as far as you note somewhere that the service will translate the spreadsheet (or any other) id to file id.
ps.: Strange that the drive api accepts spreadsheet
id
s, but the spreadsheet api does not accept fileid
s.I hit the same wall today and what I found is the
resourceId
returned by the watch method is not the same as I sent.The documentation says:
Since you are using the same name for those properties and not mentioning anywhere that these are not the same, it is not a miracle that some people gets confused. Please repopen and fix it in the documentation. I assume the returned
resourceId
is related to the channel itself, and not to the watched resource.Yep, having the same problem here. Does anybody have a solution on this? How should we get resourceId if not stored?