JMPerez / spotify-web-api-js

A client-side JS wrapper for the Spotify Web API
https://jmperezperez.com/spotify-web-api-js/
MIT License
1.87k stars 264 forks source link

addTracksToPlaylist needs an extra parameter #159

Open LuisAlvarez98 opened 4 years ago

LuisAlvarez98 commented 4 years ago

Hello this is my first time posting an issue on github. I don't know if here is the place to report something like this but I had an issue with the API call addTracksToPlaylists. I was trying to using it with the params: playlistId and uri's list as it was told in the documentation and the API wrapper builded this url: https://api.spotify.com/v1/users/[**playlistId**]/playlists/spotify:track:5cB9BlseQteklXaJjRtZti,spotify:track:2u6CBCGo8outw3ThHk4c4l,spotify:track:3dq0YBLnSElFSWETquqtxP,spotify:track:3PS7vZHBOB3rT70CUYHagZ/tracks

and I went to the Spotify Web API site and found that the url must be formed like this: image

So I think that is needed to specify that an userId is also required to do the request properly. Because currenlty in your docs this is not being specified: image

First attempt without userId gave me a 404 error image Second attempt with userId gave me a 201 image

Desktop (please complete the following information):

JMPerez commented 4 years ago

Thanks @LuisAlvarez98 for reporting it. You are right. The user id was dropped some time ago so it's no longer necessary to send it since the playlist id is unique across all users. Spotify updated the endpoints path to accept requests for playlists without specifying the user id (see https://developer.spotify.com/documentation/web-api/reference/playlists/add-tracks-to-playlist/ for the documentation for yous specific case).

This is something that needs to be done across several endpoints (get a playlist, add items to a playlist, change playlist details, get a playlist cover image, get playlist items, remove items from playlist, reorder playlist times, replace playlist items, upload cover image.

Since it's a breaking change it needs some extra work to make sure existing integrations will work fine.

Happy to keep this as an issue to be implemented.