SpotifyAPI-NET icon indicating copy to clipboard operation
SpotifyAPI-NET copied to clipboard

AddPlaylistTrack and AddPlaylistTracks states invalid track URI

Open michael16574 opened this issue 8 years ago • 4 comments

Currently trying to use the AddPlaylistTrack and AddPlaylistTracks but the function always returns status 400, invalid track uri for the every single uri that I try to pass in. I checked in google if the uris are valid so I don't believe that is the issue. For reference, here is one working URI that is not passing. 2oUmr2Kaxup6iOglqK0FK3

The error message is specifically "Invalid track uri: 2oUmr2Kaxup6iOglqK0FK3"

michael16574 avatar Aug 01 '18 22:08 michael16574

2oUmr2Kaxup6iOglqK0FK3 isn't a valid URI, it's a track ID. The URI would be spotify:track:2oUmr2Kaxup6iOglqK0FK3

jscholes avatar Aug 01 '18 22:08 jscholes

Oh ok thanks for the heads up! I followed what it said in the documentation for the format so that confused me a bit. Also, it looks like I got it to work but it only inputs 100 songs into a playlist? Do I need to manually split the array or did I miss a setting that I need to set?

michael16574 avatar Aug 01 '18 22:08 michael16574

A maximum of 100 tracks can be added in one request. https://developer.spotify.com/documentation/web-api/reference/playlists/add-tracks-to-playlist/

h-philip avatar Aug 01 '18 23:08 h-philip

Yes, 100 is the maximum, you need to loop it. I also recommend checking if the track is local as it won't work then.

if (URI.Substring("spotify:".Length, "local".Length) != "local")

Gruhlum avatar Aug 01 '18 23:08 Gruhlum