john Doe
john Doe

Reputation: 13

Trouble with spotipy user_playlist_add_tracks() Invalid track URI

When I run the code: sp.user_playlist_add_tracks(user='-me-', playlist_id='-myplaylist-', tracks='4OENnoidV0h8gJV6bhrw7r', position=None)

I get the error:

spotipy.exceptions.SpotifyException: http status: 400, code:-1 - https://api.spotify.com/v1/users/ot9a8ai4mlzof9ojqyuu6gxmm/playlists/4eohT1jHcXuYfqICXQTpNb/tracks: Invalid track uri: spotify:track:4

Note: 4OENnoidV0h8gJV6bhrw7r is a valid track id verified by print(sp.audio_features('4iV5W9uYEdYUVa79Axb7Rh'))

I assume the error is me not understanding the proper formating for spotipy's track input. The spotipy documentation simply says that the input for tracks= is "tracks - a list of track URIs, URLs or IDs"

Any help would be appreciated, thanks.

Upvotes: 1

Views: 1488

Answers (1)

Miguel Ángel
Miguel Ángel

Reputation: 323

Tracks parameter is expecting a list, so try this:

sp.user_playlist_add_tracks(
    user='-me-',
    playlist_id='-myplaylist-',
    tracks=['-song_uri-'],
    position=None)

Upvotes: 3

Related Questions