spotify / web-api

This issue tracker is no longer used. Join us in the Spotify for Developers forum for support with the Spotify Web API ➡️ https://community.spotify.com/t5/Spotify-for-Developers/bd-p/Spotify_Developer
981 stars 79 forks source link

400 Error Attempting to Remove a Track from a Playlist #206

Closed JMPerez closed 6 years ago

JMPerez commented 8 years ago

related: https://github.com/JMPerez/spotify-dedup/issues/15

I'm getting 400 Bad Request status code from the Web API when trying to remove 100 tracks from a playlist, which should be supported according to the docs. The request is:

curl 'https://api.spotify.com/v1/users/jmperezperez/playlists/5cZREFLUZxhSHP3Kznw06W/tracks' -X DELETE -H 'Origin: https://jmperezperez.com' -H 'Accept-Encoding: gzip, deflate, sdch' -H 'Accept-Language: en-US,en;q=0.8,es;q=0.6' -H 'Authorization: Bearer <edited>' -H 'Content-Type: text/plain;charset=UTF-8' -H 'Accept: */*' -H 'Referer: https://jmperezperez.com/spotify-dedup/' -H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.110 Safari/537.36' -H 'Connection: keep-alive' -H 'DNT: 1' --data-binary '{"tracks":[{"uri":"spotify:track:4dL1HwRWQgWK9timX9PLex","positions":[883]},{"uri":"spotify:track:4JehYebiI9JE8sR8MisGVb","positions":[898]},{"uri":"spotify:track:1cRNEme8Bp7V8eNIAeyiAk","positions":[907]},{"uri":"spotify:track:2Nu0P68oruhup6YcAi8On3","positions":[915]},{"uri":"spotify:track:5Ic7xfvSlj5Jpyi93hExGi","positions":[927]},{"uri":"spotify:track:7pJgjBf82BrUQ3z7HdQvW1","positions":[949]},{"uri":"spotify:track:53b7YqVw2Vc1oRrYeOm7z7","positions":[954]},{"uri":"spotify:track:5h9pB5af60LWJBrG1HCHsU","positions":[961]},{"uri":"spotify:track:0mYPfHvPzoUZJ2puHRyzyf","positions":[998]},{"uri":"spotify:track:0VYQK5I08homNvX8SRS37R","positions":[1005]},{"uri":"spotify:track:70hWOTDBrLrZUfMdQnTI9l","positions":[1016]},{"uri":"spotify:track:2PpruBYCo4H7WOBJ7Q2EwM","positions":[1026]},{"uri":"spotify:track:24YvUQnuPL8gObCfSnAobH","positions":[1029]},{"uri":"spotify:track:2zqv41wBo09liJyULPJccc","positions":[1030]},{"uri":"spotify:track:2hsza71y54ABzmabyNDtM4","positions":[1032]},{"uri":"spotify:track:35WhawODuOs0kaHxwmPA9D","positions":[1038]},{"uri":"spotify:track:089vxHEH64AKLKhokNXEJx","positions":[1045]},{"uri":"spotify:track:0ho4ac5tM9CNcmeIElhadF","positions":[1059]},{"uri":"spotify:track:0ZvUdZndc4SckH6ivQwxdL","positions":[1063]},{"uri":"spotify:track:2Hwm1eMBz0tJx6hlzuz5ud","positions":[1075]},{"uri":"spotify:track:6KM6693N1wVvz6tDviEF4F","positions":[1088]},{"uri":"spotify:track:0eqH0ALoDQevq59YcQ53KE","positions":[1089]},{"uri":"spotify:track:2DvDmy9aCv9TajH0MkHsXa","positions":[1099]},{"uri":"spotify:track:5SmXEPnevlRjBPWBG7oKIi","positions":[1107]},{"uri":"spotify:track:0oXuKhuNkXiZtuoxrdt3Ca","positions":[1118]},{"uri":"spotify:track:0oXuKhuNkXiZtuoxrdt3Ca","positions":[1119]},{"uri":"spotify:track:18eoNBn1L1li2TvPa2DupB","positions":[1121]},{"uri":"spotify:track:1y4eb6hmAvsqlDOl3fx9kk","positions":[1123]},{"uri":"spotify:track:6dKJWmXeYPznzolqo4K6Uq","positions":[1129]},{"uri":"spotify:track:7CFQrZR4WeKEg4vweqp8Gv","positions":[1142]},{"uri":"spotify:track:70VjMtwhm3Q2HBQeJnPfmh","positions":[1162]},{"uri":"spotify:track:0q9Ry3wxCrf0jQvuvs46sz","positions":[1173]},{"uri":"spotify:track:4N8UShrxz5xVJw7yBMGeVj","positions":[1174]},{"uri":"spotify:track:1ccNXmmgYnajJ8ulYYEK9Y","positions":[1218]},{"uri":"spotify:track:4vp2J1l5RD4gMZwGFLfRAu","positions":[1230]},{"uri":"spotify:track:72np30cEzvqzxAUG5mrhyT","positions":[1231]},{"uri":"spotify:track:14iN3o8ptQ8cFVZTEmyQRV","positions":[1241]},{"uri":"spotify:track:005lwxGU1tms6HGELIcUv9","positions":[1242]},{"uri":"spotify:track:6a8GbQIlV8HBUW3c6Uk9PH","positions":[1250]},{"uri":"spotify:track:5aaBnBs9YyfexG7lOH4MZP","positions":[1263]},{"uri":"spotify:track:29viePXNqWUw1cxqzOcuOD","positions":[1264]},{"uri":"spotify:track:6rFKHZniKTOhcYnw5T55Bw","positions":[1271]},{"uri":"spotify:track:5dhQCqONiQji7k4RkhIcjq","positions":[1272]},{"uri":"spotify:track:173PnvZh4grHTf31DPXDbJ","positions":[1279]},{"uri":"spotify:track:5TAf4lnZCZTLlZHNZMLFLi","positions":[1296]},{"uri":"spotify:track:2k1np6GRFvKjgjYfo2g39B","positions":[1302]},{"uri":"spotify:track:7yqU5HODQU91zj8ahUaUX1","positions":[1303]},{"uri":"spotify:track:084rSHN2xIfUrwShDgzk1Q","positions":[1304]},{"uri":"spotify:track:3gkQyMVLWI2A2BELNOv87g","positions":[1307]},{"uri":"spotify:track:41ViNOa85jwxmEiRnGuG5P","positions":[1310]},{"uri":"spotify:track:41ViNOa85jwxmEiRnGuG5P","positions":[1311]},{"uri":"spotify:track:60UZlV9G08xkjcmwsiVteK","positions":[1315]},{"uri":"spotify:track:6J8IwGX3oHi7x9B57vmMMW","positions":[1316]},{"uri":"spotify:track:47BBI51FKFwOMlIiX6m8ya","positions":[1320]},{"uri":"spotify:track:42vuwIlurZqLrHsFYr1pin","positions":[1321]},{"uri":"spotify:track:25QHT4hGAeTUkMXfQkPlJJ","positions":[1329]},{"uri":"spotify:track:6izhPbUU3CeMYvTT74YHnb","positions":[1332]},{"uri":"spotify:track:4gJxLdiZXkKiSbvpFHNu8n","positions":[1339]},{"uri":"spotify:track:05pKAafT85jeeNhZ6kq7HT","positions":[1345]},{"uri":"spotify:track:5xuu2VJq5QaMO7gLHiI8PZ","positions":[1364]},{"uri":"spotify:track:37fGGrNQgxZ3qGOvAebg9i","positions":[1384]},{"uri":"spotify:track:4sUoWHVnJl8z3t4zdqf6xB","positions":[1385]},{"uri":"spotify:track:2ze7s5CrESggiWA3RpDYIy","positions":[1386]},{"uri":"spotify:track:003qa9jZ2byfApC0hBnr0G","positions":[1407]},{"uri":"spotify:track:2jHujamO9UuZv8im9eLdOB","positions":[1408]},{"uri":"spotify:track:3S0OXQeoh0w6AY8WQVckRW","positions":[1411]},{"uri":"spotify:track:57URzGoYgSj0AiXclvqD6y","positions":[1412]},{"uri":"spotify:track:5UqqOfFa9DYXALpCCF8VwB","positions":[1414]},{"uri":"spotify:track:0A8HK5hV5SgywiKKrBPKDU","positions":[1423]},{"uri":"spotify:track:26NX1wPt1TRCH536yocd6i","positions":[1432]},{"uri":"spotify:track:2hdy9Wt9qp7M7d0U3ossu2","positions":[1437]},{"uri":"spotify:track:360UM2DaiHZPRu0EsrOvMp","positions":[1439]},{"uri":"spotify:track:1EQgbMBc304Ss86dXBulJA","positions":[1443]},{"uri":"spotify:track:3wvg3Jpee5NzpSBZhBqFdE","positions":[1444]},{"uri":"spotify:track:4rIEkt9wgcmoIJtiRcvtNX","positions":[1447]},{"uri":"spotify:track:3zSCNTXI7Ed0PiidZVmzIe","positions":[1449]},{"uri":"spotify:track:5vE7vbd9Q2Rgw4JqtkD3pe","positions":[1451]},{"uri":"spotify:track:16sbugRbf9xEKlekuQ7Whm","positions":[1456]},{"uri":"spotify:track:7iL6o9tox1zgHpKUfh9vuC","positions":[1463]},{"uri":"spotify:track:6Kh4FkETk9i3EUVTerZEuY","positions":[1484]},{"uri":"spotify:track:00IEQOqwlB0hngGY9zD3Bw","positions":[1488]},{"uri":"spotify:track:2julHzta3pq6E1ugxyvsbj","positions":[1525]},{"uri":"spotify:track:0U0mMRtYifdTaRltbemBee","positions":[1526]},{"uri":"spotify:track:0OaunKfsxkgBvPv68jBbmm","positions":[1532]},{"uri":"spotify:track:0RUGuh2uSNFJpGMSsD1F5C","positions":[1534]},{"uri":"spotify:track:2AW37v0bDyuOzGP3XnmFuA","positions":[1539]},{"uri":"spotify:track:4TmGtGkkmaoXRCvpOwDJoO","positions":[1542]},{"uri":"spotify:track:2fOxxLz9JVe53itq6pfBak","positions":[1544]},{"uri":"spotify:track:5TgD3Wh5ZUZnUU4tmVvJbx","positions":[1551]},{"uri":"spotify:track:7g7tyb8zM9UeKsdvosW9W3","positions":[1557]},{"uri":"spotify:track:1Pje5DSZWSD1JLEZVx7Fma","positions":[1562]},{"uri":"spotify:track:43btz2xjMKpcmjkuRsvxyg","positions":[1563]},{"uri":"spotify:track:59wpu37k02o2UGZIPpcSPd","positions":[1567]},{"uri":"spotify:track:6jHKJ5sennAgsNI6m15VO0","positions":[1576]},{"uri":"spotify:track:0vYMzeTmfbnrAhGPRcJqVP","positions":[1580]},{"uri":"spotify:track:1sgfjgLRCqSfndpofU8T2C","positions":[1583]},{"uri":"spotify:track:79ek2oolIYyGUO4aVK5IY2","positions":[1585]},{"uri":"spotify:track:7rr5DQM980mOF1UtIC4q6v","positions":[1594]},{"uri":"spotify:track:4pmc2AxSEq6g7hPVlJCPyP","positions":[1605]},{"uri":"spotify:track:513Pk2WNJaTGMjqD4AuQ8T","positions":[1616]}]}' --compressed

Thanks for looking into it.

JMPerez commented 8 years ago

I think I have isolated the issue. Take this example:

I would like to delete track in position 905 from the playlist spotify:user:jmperezperez:playlist:5cZREFLUZxhSHP3Kznw06W. See https://developer.spotify.com/web-api/console/get-playlist-tracks/?playlist_id=5cZREFLUZxhSHP3Kznw06W&user_id=jmperezperez&limit=1&offset=905. The track to remove is spotify:track:1cRNEme8Bp7V8eNIAeyiAk.

Great, let's try to delete it. See https://developer.spotify.com/web-api/console/delete-playlist-tracks?playlist_id=5cZREFLUZxhSHP3Kznw06W&body-json=%7B%0D%0A++%22tracks%22%3A+%5B%0D%0A++++%7B%0D%0A++++++%22positions%22%3A+%5B905%5D%2C%0D%0A++++++%22uri%22%3A+%22spotify%3Atrack%3A1cRNEme8Bp7V8eNIAeyiAk%22%0D%0A++++%7D%0D%0A++%5D%0D%0A%7D&user_id=jmperezperez. This throws a 400 Bad request status code.

relevitt commented 8 years ago

Sounds like it might be the same issue as this ... https://github.com/spotify/web-api/issues/192.

If so, this solution worked for me:

'Had a look at this. My initial thought is on how you get those track IDs. This is what I think may be happening: You get the playlist with a market parameter, this will trigger relinking behaviour. You can read about it here: https://developer.spotify.com/web-api/track-relinking-guide/

In short, you are operating on a relinked track ID when you should use the relinked_from items track ID.'

JMPerez commented 8 years ago

@relevitt The difference in this case is that I'm not using the market parameter when fetching the playlist tracks, just limit and offset.

JMPerez commented 8 years ago

I think I have found another instance of this issue. Playlist spotify:user:jmperezperez:playlist:628od5L2MOk9Q5qZIv6U5I trying to delete track with position 692 (Hypnotize by System of a Down).

arirawr commented 6 years ago

Closing this issue as we haven't been able to reproduce the behaviour. Feel free to reopen with reproduction steps if you are still seeing the issue!