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.

>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"

Leave a Reply