Announcements

Help Wizard

Step 1

NEXT STEP

Updating playlist cover image with base64 data

Updating playlist cover image with base64 data

Plan

Premium

Device

(iPhone 12)

Operating System

(iOS 15)

 

My Question or Issue

Hi. I'm using iOS Shortcuts app as a low code environment for some simple Spotify API activities. Authentication is working and I'm able to GET and POST with other Spotify APIs (e.g. update playlist tracks, update playlist description). As other forum posts have observed, there's not a lot of detail on how to actually use the Add Custom Playlist Cover Image API. I've authenticated the app with ugc-image-upload, playlist-modify-public, playlist-modify-private scope.

 

I'm making a PUT call to https://api.spotify.com/v1/playlists/{my playlist ID}/images with headers Accept: application/json, Content-Type: image/jpeg (I've also tried application/json), and Authorization: Bearer {token}

 

I've encoded my image filed with base64 and confirmed there's no preface text with image/jpeg. My question is how to actually post the encoded image data? I don't think it's part of the URL call (https://api.spotify.com/ ... /images/image=), but rather in the request body. But using a tag of some kind, as a file, etc? All of my various attempts are generating a 400 error: "Bad request"

 

278939379_589033832116759_5230463481113517230_n.jpg

 

Can anyone shed more light on this? Any verified examples to point to that would show URL, header and body elements? Thanks!

Reply
4 Replies

did you ever figure this out by any chance? Trying to do something similar and running into the same issue.

5 minutes ago I would have said, still no luck, but I changed one parameter and actually had success for the first time. The trick seems to have been in the encoding -- looks like there may have been line breaks (every 64 characters) that was messing this up. Switching to no line breaks and sending the encoded image as a file is working for me now.

Think you could provide an example of this? Thanks!!

I’m not sure how much iOS Shortcuts pseudo code will help here. Here’s a sample shortcut that gets a random Bob’s Burgers image and encodes to base64. https://www.icloud.com/shortcuts/3cc13e2e68dc45598bd56792fb01044a

Once I have the encoded image, I pass that to the Spotify endpoint using PUT, content type image/jpeg, and the encoded image in the body request. Hope that helps a little. 

 

9578D581-1B17-45FD-BC4C-7A314EA290AC.jpeg

Suggested posts