Open Dcai169 opened 4 years ago
The Spotify documentation is correct. In fact the implementation is correct too, it's just the JSDoc
comment that is incorrect. Valid keys for options
are deviceIds
and play
. You have device_ids
, change that to deviceIds
and you're good to go. See the excerpt from the source code below:
/**
* Transfer a User's Playback
* @param {Object} [options] Options, being market.
* @param {requestCallback} [callback] Optional callback method to be called instead of the promise.
* @returns {Promise|undefined} A promise that if successful, resolves into a paging object of tracks,
* otherwise an error. Not returned if a callback is given.
*/
transferMyPlayback: function(options, callback) {
return WebApiRequest.builder(this.getAccessToken())
.withPath('/v1/me/player')
.withHeaders({ 'Content-Type': 'application/json' })
.withBodyParameters({
device_ids: options.deviceIds,
play: !!options.play
})
.build()
.execute(HttpManager.put, callback);
}
Your comment was a life saver @konstantinjdobler, I had read through that function over and over but somehow missed that the field name in options was lower camel case. I had been using device_ids
.
I'm building an application where nodejs opens a website that uses the Spotify Web Playback SDK. When the Playback SDK is ready, it sends its
device_id
to the server where it is being hosted. When looking at the current documentation of thespotifyWebApi.transferMyPlayback()
method, on line 1074, it says that valid options for this endpoint areComparing this with Spotify's docs which state:
{device_ids:["74ASZWbe4lXaubB36ztrGX"]}
Note: Although an array is accepted, only a single device_id is currently supported. Supplying more than one will return 400 Bad RequestI want to know what the correct usage is, as my current implementation is not functional.
Bring your attention to the function
transferToNewActiveDevice()
in the code below: (Please excuse poor code; I'm a first-time JS dev)