Summary
The function add_to_queue currently passes the data, which is a dict constructed of uri and optionally device_id, as request body (data=) instead of query parameters (params=).
According to the API specification those parameters should be passed as query parameters, see https://developer.spotify.com/documentation/web-api/reference/add-to-queue
Suggested Fix
This is simply fixed by using params= instead of data= in spotifyaio/spotify.py:437
async def add_to_queue(self, uri: str, device_id: str | None = None) -> None:
"""Add to queue."""
data: dict[str, str] = {"uri": uri}
if device_id:
data["device_id"] = device_id
await self._post("v1/me/player/queue", params=data)
Impact
All calls to add_to_queue silently fail, the Spotify API doesn't receive the params, nothing is added to the queue.
This can for example be observed in Home Assistant when issuing the following Action
action: media_player.play_media
target:
entity_id: media_player.spotify # or whatever the Spotify Entity Id is
data:
media_content_id: "spotify:track:0C80GCp0mMuBzLf3EAXqxv"
media_content_type: track
enqueue: add # This should add the track to the queue
A simple monkey-patch in such environment already confirms the fix is working.
Summary
The function
add_to_queuecurrently passes the data, which is a dict constructed ofuriand optionallydevice_id, as request body (data=) instead of query parameters (params=).According to the API specification those parameters should be passed as query parameters, see https://developer.spotify.com/documentation/web-api/reference/add-to-queue
Suggested Fix
This is simply fixed by using
params=instead ofdata=in spotifyaio/spotify.py:437Impact
All calls to
add_to_queuesilently fail, the Spotify API doesn't receive the params, nothing is added to the queue.This can for example be observed in Home Assistant when issuing the following Action
A simple monkey-patch in such environment already confirms the fix is working.