[GH-ISSUE #480] Spotipy fails to use correct Playlist uri #280

Closed
opened 2026-02-27 23:21:46 +03:00 by kerem · 3 comments
Owner

Originally created by @fahim-hamid on GitHub (Apr 25, 2020).
Original GitHub issue: https://github.com/spotipy-dev/spotipy/issues/480

Spotipy doesnt use the correct uri when using the user_playlist_add_tracks() method, even when explictly set

using the following code (the playlist and user ids don't seem to be part of the problem)
sp.user_playlist_add_tracks( user['id'], playlist['id'], 'spotify:track:1c1Okhc1Ubk2bHGvxrNAim,spotify:track:3cLsdnXjn3vtNQBzJXtPGH')

returns the following error log

ERROR:spotipy.client:HTTP Error for POST to https://api.spotify.com/v1/users/3f8k783hsz6m24pkhua5bl23o/playlists/0ZkTdVvn83jQW8LkIfNbkO/tracks returned 400 due to Invalid track uri: spotify:track:s
Traceback (most recent call last):
  File "/home/fahim/Documents/EllIOT/venv/lib/python3.8/site-packages/spotipy/client.py", line 170, in _internal_call
    response.raise_for_status()
  File "/home/fahim/Documents/EllIOT/venv/lib/python3.8/site-packages/requests/models.py", line 941, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 400 Client Error: Bad Request for url: https://api.spotify.com/v1/users/3f8k783hsz6m24pkhua5bl23o/playlists/0ZkTdVvn83jQW8LkIfNbkO/tracks

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/fahim/Documents/EllIOT/src/Integrations/spotify.py", line 63, in <module>
    create_temp_playlist(get_top_tracks('Pewdiepie'))
  File "/home/fahim/Documents/EllIOT/src/Integrations/spotify.py", line 61, in create_temp_playlist
    sp.user_playlist_add_tracks(user['id'],playlist['id'],'spotify:track:1c1Okhc1Ubk2bHGvxrNAim,spotify:track:3cLsdnXjn3vtNQBzJXtPGH')
  File "/home/fahim/Documents/EllIOT/venv/lib/python3.8/site-packages/spotipy/client.py", line 680, in user_playlist_add_tracks
    return self._post(
  File "/home/fahim/Documents/EllIOT/venv/lib/python3.8/site-packages/spotipy/client.py", line 210, in _post
    return self._internal_call("POST", url, payload, kwargs)
  File "/home/fahim/Documents/EllIOT/venv/lib/python3.8/site-packages/spotipy/client.py", line 181, in _internal_call
    raise SpotifyException(
spotipy.exceptions.SpotifyException: http status: 400, code:-1 - https://api.spotify.com/v1/users/3f8k783hsz6m24pkhua5bl23o/playlists/0ZkTdVvn83jQW8LkIfNbkO/tracks:
 Invalid track uri: spotify:track:s

and then finally ending with a exit code 1

I'm using a venv with Pycharm Proffessional 2020.1 with Python 3.8

Originally created by @fahim-hamid on GitHub (Apr 25, 2020). Original GitHub issue: https://github.com/spotipy-dev/spotipy/issues/480 Spotipy doesnt use the correct uri when using the user_playlist_add_tracks() method, even when explictly set using the following code (the playlist and user ids don't seem to be part of the problem) `sp.user_playlist_add_tracks( user['id'], playlist['id'], 'spotify:track:1c1Okhc1Ubk2bHGvxrNAim,spotify:track:3cLsdnXjn3vtNQBzJXtPGH')` returns the following error log ``` ERROR:spotipy.client:HTTP Error for POST to https://api.spotify.com/v1/users/3f8k783hsz6m24pkhua5bl23o/playlists/0ZkTdVvn83jQW8LkIfNbkO/tracks returned 400 due to Invalid track uri: spotify:track:s Traceback (most recent call last): File "/home/fahim/Documents/EllIOT/venv/lib/python3.8/site-packages/spotipy/client.py", line 170, in _internal_call response.raise_for_status() File "/home/fahim/Documents/EllIOT/venv/lib/python3.8/site-packages/requests/models.py", line 941, in raise_for_status raise HTTPError(http_error_msg, response=self) requests.exceptions.HTTPError: 400 Client Error: Bad Request for url: https://api.spotify.com/v1/users/3f8k783hsz6m24pkhua5bl23o/playlists/0ZkTdVvn83jQW8LkIfNbkO/tracks During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/home/fahim/Documents/EllIOT/src/Integrations/spotify.py", line 63, in <module> create_temp_playlist(get_top_tracks('Pewdiepie')) File "/home/fahim/Documents/EllIOT/src/Integrations/spotify.py", line 61, in create_temp_playlist sp.user_playlist_add_tracks(user['id'],playlist['id'],'spotify:track:1c1Okhc1Ubk2bHGvxrNAim,spotify:track:3cLsdnXjn3vtNQBzJXtPGH') File "/home/fahim/Documents/EllIOT/venv/lib/python3.8/site-packages/spotipy/client.py", line 680, in user_playlist_add_tracks return self._post( File "/home/fahim/Documents/EllIOT/venv/lib/python3.8/site-packages/spotipy/client.py", line 210, in _post return self._internal_call("POST", url, payload, kwargs) File "/home/fahim/Documents/EllIOT/venv/lib/python3.8/site-packages/spotipy/client.py", line 181, in _internal_call raise SpotifyException( spotipy.exceptions.SpotifyException: http status: 400, code:-1 - https://api.spotify.com/v1/users/3f8k783hsz6m24pkhua5bl23o/playlists/0ZkTdVvn83jQW8LkIfNbkO/tracks: Invalid track uri: spotify:track:s ``` and then finally ending with a exit code 1 I'm using a venv with Pycharm Proffessional 2020.1 with Python 3.8
kerem 2026-02-27 23:21:46 +03:00
  • closed this issue
  • added the
    question
    label
Author
Owner

@stephanebruckert commented on GitHub (Apr 25, 2020):

tracks should be a list of ids

<!-- gh-comment-id:619411897 --> @stephanebruckert commented on GitHub (Apr 25, 2020): `tracks` should be a list of ids
Author
Owner

@fahim-hamid commented on GitHub (Apr 25, 2020):

I’ve tried it with uri’s,ids and Spotify links but they all more or less return the same error

<!-- gh-comment-id:619441133 --> @fahim-hamid commented on GitHub (Apr 25, 2020): I’ve tried it with uri’s,ids and Spotify links but they all more or less return the same error
Author
Owner

@stephanebruckert commented on GitHub (Apr 25, 2020):

Have you tried to put the ids in a list? Like so:

sp.user_playlist_add_tracks(user['id'], playlist['id'], 
                            ['spotify:track:1c1Okhc1Ubk2bHGvxrNAim', 'spotify:track:3cLsdnXjn3vtNQBzJXtPGH'])
<!-- gh-comment-id:619453870 --> @stephanebruckert commented on GitHub (Apr 25, 2020): Have you tried to put the ids in a list? Like so: sp.user_playlist_add_tracks(user['id'], playlist['id'], ['spotify:track:1c1Okhc1Ubk2bHGvxrNAim', 'spotify:track:3cLsdnXjn3vtNQBzJXtPGH'])
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/spotipy#280
No description provided.