Spotipy: user_playlist_add_track error

Created on 25 Jul 2014  路  1Comment  路  Source: plamere/spotipy

Hey I'm just starting to get familiar with the api, and I'm just trying out a simple task. I'm trying to add the top 3 tracks of a given artist to a playlist.

I know authentication worked because I can access the playlists, and I set my scope to playlist-modify-private and public.

I use the following command:

sp.user_playlist_add_tracks(user, playlist_id, song['uri'])

This is the value of song['uri']:

song_uri
Out[20]: u'spotify:track:2Zb7wnGUnNPCas2E0wWSQ5'

Here's the error message:

http status: 400, code:-1 - the requested resource could not be found: https://api.spotify.com/v1/users/121142162/playlists/3LhmfLB345HX1tty3Z99u7/tracks?uris=s%2Cp%2Co%2Ct%2Ci%2Cf%2Cy%2C%3A%2Ct%2Cr%2Ca%2Cc%2Ck%2C%3A%2C2%2CZ%2Cb%2C7%2Cw%2Cn%2CG%2CU%2Cn%2CN%2CP%2CC%2Ca%2Cs%2C2%2CE%2C0%2Cw%2CW%2CS%2CQ%2C5

It seems like the uri's match up, ignoring how colons were decoded. Any ideas what the issue is?

Most helpful comment

song['uri'] needs to be a list.

Note the method is user_playlist_add_tracks() (tracks being plural).

Just wrap the track in brackets:
sp.user_playlist_add_tracks(user, playlist_id, [song['uri']])

>All comments

song['uri'] needs to be a list.

Note the method is user_playlist_add_tracks() (tracks being plural).

Just wrap the track in brackets:
sp.user_playlist_add_tracks(user, playlist_id, [song['uri']])

Was this page helpful?
0 / 5 - 0 ratings