svrooij / node-sonos-ts

:speaker: Sonos control library, use this library in your own appliction.
https://sonos-ts.svrooij.io/
MIT License
81 stars 18 forks source link

ContentDirectoryService - Browse -throws an error #107

Closed hklages closed 3 years ago

hklages commented 3 years ago

The command:

const basicFavorites = await kidsPlayer.ContentDirectoryService.Browse('FV:2', 'BrowseDirectChildren', '*', 0, 200, '')

throws an error:

{"stack":"SonosError: Sonos error on Browse UPnPError 402 (Invalid args)\n    at ContentDirectoryService.handleErrorResponse (C:\\Users\\hekla\\Development\\kidsplayer\\node_modules\\@svrooij\\sonos\\lib\\services\\base-service.js:223:23)\n    at processTicksAndRejections (internal/process/task_queues.js:93:5)\n    at async ContentDirectoryService.handleRequestAndParseResponse (C:\\Users\\hekla\\Development\\kidsplayer\\node_modules\\@svrooij\\sonos\\lib\\services\\base-service.js:196:15)\n    at async ContentDirectoryService.SoapRequestWithBody (C:\\Users\\hekla\\Development\\kidsplayer\\node_modules\\@svrooij\\sonos\\lib\\services\\base-service.js:90:16)\n    at async ContentDirectoryService.Browse (C:\\Users\\hekla\\Development\\kidsplayer\\node_modules\\@svrooij\\sonos\\lib\\services\\content-directory.service.js:74:34)\n    
at async asynWrapperPlayIt (C:\\Users\\hekla\\Development\\kidsplayer\\playit-all.js:47:25)","message":"Sonos error on Browse UPnPError 402 (Invalid args)","Action":"Browse","FaultCode":"s:Client","Fault":"UPnPError","UpnpErrorCode":402,"UpnpErrorDescription":"Invalid args","name":"SonosError"}

while on the other hand same arguments work find an ExecuteCommand:

const basicFavorites = await kidsPlayer.ExecuteCommand('ContentDirectoryService.Browse', {
        ObjectID: 'FV:2', BrowseFlag: 'BrowseDirectChildren', Filter: '*',
        StartingIndex: 0, RequestedCount: 200, SortCriteria: ''
            })
svrooij commented 3 years ago

It are not the same arguments, the second one sends an object. And the first one send the correct parameters but as arguments.

each call to a service requires to send exactly one (or zero) arguments, where the argument always is an object. If your code was typescript it would not compile.