Hey everyone, I’m having trouble adding tracks to a Spotify playlist through the API server. I’ve tried a few things but keep hitting roadblocks.
First, I attempted to POST the track URI as mentioned in the docs:
["spotify:track:1lDWb6b6ieDQ2xT7ewTC3G"]
But I got an “Invalid input” error. Then I tried just the track ID:
["1lDWb6b6ieDQ2xT7ewTC3G"]
This time it said “No valid tracks”.
I also tried POSTing to localhost:1337/playlist/{playlist_id}/add?index but got a “Bad parameter” error about index needing to be numeric. Adding index=1 seemed to work, but I’m not sure if that’s right.
I’m working in PHP but would appreciate any tips, even command line examples I can adapt. Thanks for any help!
I’ve dealt with this exact issue before, and it can be frustrating. Here’s what worked for me:
Make sure you’re using the correct endpoint: /v1/playlists/{playlist_id}/tracks
Your request body should be JSON formatted like this:
{“uris”: [“spotify:track:1lDWb6b6ieDQ2xT7ewTC3G”]}
Don’t forget to set the Content-Type header to application/json and include your access token in the Authorization header.
If you’re still getting errors, it might be a permissions issue. Check that your access token has the playlist-modify-public or playlist-modify-private scope, depending on the playlist’s visibility.
Also, ensure you’re the owner of the playlist or have been given edit access. The API won’t let you modify playlists you don’t have permission for.
Hope this helps you get it working!
I’ve worked with the Spotify API extensively, and I can offer some insights on appending tracks to playlists. The key is using the correct endpoint: /v1/playlists/{playlist_id}/tracks. Your request body should be JSON-formatted with the full track URIs:
{“uris”: [“spotify:track:1lDWb6b6ieDQ2xT7ewTC3G”]}
Ensure your POST request includes the proper Authorization header with a valid access token and set Content-Type to application/json. Regarding the index parameter, it’s optional; omitting it will add tracks to the end of the playlist. If you’re still encountering issues, verify that your access token has the necessary scopes (playlist-modify-public or playlist-modify-private) and that you have edit permissions for the playlist in question. In PHP, you can use cURL to make the API request. Let me know if you need help with the implementation.
I’ve encountered similar issues when working with the Spotify API. From my experience, the most reliable method is to use the /v1/playlists/{playlist_id}/tracks endpoint. Make sure you’re sending a POST request with the proper authorization header and content type.
The body of your request should be in JSON format, like this:
{“uris”: [“spotify:track:1lDWb6b6ieDQ2xT7ewTC3G”]}
If you’re still getting errors, double-check your access token and ensure it has the proper scopes. Also, verify that you have the necessary permissions for the playlist you’re trying to modify.
As for the index parameter, it’s optional. If omitted, Spotify will append the tracks to the end of the playlist by default. Hope this helps!
hey mate, i’ve been there too. try using the full track URI in your request body like this:
{“uris”: [“spotify:track:1lDWb6b6ieDQ2xT7ewTC3G”]}
make sure your sending a POST to /v1/playlists/{playlist_id}/tracks with the right headers. if it still fails, check ur access token n permissions. good luck!
yo, i ran into this prob before. make sure ur using the right endpoint: /v1/playlists/{playlist_id}/tracks. the body should be like this:
{“uris”: [“spotify:track:1lDWb6b6ieDQ2xT7ewTC3G”]}
don’t forget to set headers right. if it still fails, check ur token and permissions. good luck man!
Good tip, @SoaringEagle! That’s definitely the right approach if you’re working directly with Spotify’s API. On the other hand, if you don’t want to mess around with endpoints, tokens, and permissions, MusConvtool offers a much simpler way to manage and transfer entire playlists across Spotify and other platforms in just a few clicks