Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

I cant add songs to my playlist at spotify

I try to add a song to my playlist at spotify.

Here is my code:

import requests
import json

user_id = "user_id"
playlist_id = "playlist_id"

url = f'"https://api.spotify.com/v1/playlists/{playlist_id}/tracks"'
headers = {
    'Authorization': 'Bearer secret_auth_token',
    'Content-Type': 'application/json',
}
payload = {
    "uris": ["spotify:track:64PgpLHuQK3UJ5qZ875Vei"], 
}


response = requests.post(url, headers=headers, data=json.dumps(payload))

print(response.text)

than i got this error:
requests.exceptions.InvalidSchema: No connection adapters were found for '"https://api.spotify.com/v1/playlists/2oNkSJU1mGfTAg3ii9nLwc/tracks"'

i have tested my auth token. It has necessary scopes. For example i can create playlist with this token. But i dont know why. I cant add songs to my playlist. When i try it with the code above. I am new learner if u can simplify the answer that would help a lot.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

This is due to the combination of single and double quotes you are using in your URL. Try to replace it with this and it should work as expected:

url = f"https://api.spotify.com/v1/playlists/{playlist_id}/tracks"
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading