Announcements

Help Wizard

Step 1

NEXT STEP

FAQs

Please see below the most popular frequently asked questions.

Loading article...

Loading faqs...

VIEW ALL

Ongoing Issues

Please see below the current ongoing issues which are under investigation.

Loading issue...

Loading ongoing issues...

VIEW ALL

Upload Custom Playlist Cover with Python

Upload Custom Playlist Cover with Python

My Question or Issue

Hi! I'm having trouble with uploading custom image to playlist cover. Here's my code: 

 

def add_playlist_cover(playlist_id, token):
with open('cover.jpg', 'rb') as f:
data = base64.b64encode(f.read())
auth_header = {"Authorization": f"Bearer {token}", 'Content-Type':'image/jpeg'}
url = f'https://api.spotify.com/v1/playlists/{playlist_id}/images'
r = requests.put(url, headers=auth_header, data=data)
print(r.json())

I've tried Content-Type as image/jpeg and as application/json and still got an error requests.exceptions.SSLError: HTTPSConnectionPool(host='api.spotify.com', port=443)

Can someone help me out? Thanks in advance

 

Reply
2 Replies

You can add `verify=False` inside the `requests.put()` and try if that works.

XimzendSpotify Star
Help others find this answer and click "Accept as Solution".
If you appreciate my answer, maybe give me a Like.
Note: I'm not a Spotify employee.

Did you ensure that the image is less than or equal to 256kb in size?

Suggested posts

Type a product name