[GH-ISSUE #150] $api->updatePlaylistImage is failing with unknown error #95

Closed
opened 2026-02-27 19:26:01 +03:00 by kerem · 2 comments
Owner

Originally created by @anderthalb on GitHub (Feb 7, 2019).
Original GitHub issue: https://github.com/jwilsson/spotify-web-api-php/issues/150

Hi there,

I'm using your api for quite a while now and I love it! But today I run into a problem I can't explain. Maybe I miss something and I hope you are able to help me.

I created a private user playlist (which works fine!) and now I want to set the image for the playlist. When I run the following code, I see an error:

An unknown error occurred. in .../vendor/jwilsson/spotify-web-api-php/src/Request.php:45

This is the code:

// Cover
$imageDataRaw = base64_encode(file_get_contents(__DIR__.'/cover.jpg'));
$imageData = $imageDataRaw;
// $imageData = 'data:image/jpeg;base64,' . $imageDataRaw;
try {
  $cover = $api->updatePlaylistImage($playlist->id, $imageData);
} catch (Exception $e) {
  echo $playlist->external_urls->spotify . PHP_EOL . PHP_EOL . '<br><br>';
  echo $playlist->id . PHP_EOL . PHP_EOL . '<br><br>';
  die($e);
}

$playlist->id is correkt and when I enter $playlist->external_urls->spotify I can see the correkt playlist.

Private Playlists are generated for a special "backend-"user I use. This user has granted the scopes ['playlist-modify-public', 'playlist-modify-private']. Everything works fine, but the image update.

The image itself is around 95kb and the base64-code arount 130kb ... should be ok too.

Any ideas?

Originally created by @anderthalb on GitHub (Feb 7, 2019). Original GitHub issue: https://github.com/jwilsson/spotify-web-api-php/issues/150 Hi there, I'm using your api for quite a while now and I love it! But today I run into a problem I can't explain. Maybe I miss something and I hope you are able to help me. I created a private user playlist (which works fine!) and now I want to set the image for the playlist. When I run the following code, I see an error: An unknown error occurred. in .../vendor/jwilsson/spotify-web-api-php/src/Request.php:45 This is the code: ``` // Cover $imageDataRaw = base64_encode(file_get_contents(__DIR__.'/cover.jpg')); $imageData = $imageDataRaw; // $imageData = 'data:image/jpeg;base64,' . $imageDataRaw; try { $cover = $api->updatePlaylistImage($playlist->id, $imageData); } catch (Exception $e) { echo $playlist->external_urls->spotify . PHP_EOL . PHP_EOL . '<br><br>'; echo $playlist->id . PHP_EOL . PHP_EOL . '<br><br>'; die($e); } ``` $playlist->id is correkt and when I enter $playlist->external_urls->spotify I can see the correkt playlist. Private Playlists are generated for a special "backend-"user I use. This user has granted the scopes ['playlist-modify-public', 'playlist-modify-private']. Everything works fine, but the image update. The image itself is around 95kb and the base64-code arount 130kb ... should be ok too. Any ideas?
kerem closed this issue 2026-02-27 19:26:01 +03:00
Author
Owner

@jwilsson commented on GitHub (Feb 7, 2019):

Hi!
Does the user also have the ugc-image-upload scope? And does it work when using something like cURL for example?

Because the code looks correct to me!

<!-- gh-comment-id:461543104 --> @jwilsson commented on GitHub (Feb 7, 2019): Hi! Does the user also have the `ugc-image-upload` scope? And does it work when using something like cURL for example? Because the code looks correct to me!
Author
Owner

@anderthalb commented on GitHub (Feb 11, 2019):

Yes, it was the missing "ugc-image-upload" scope. I knew that once, but forgot it ... many thanks for the hint!

Cheers, Christian

<!-- gh-comment-id:462266779 --> @anderthalb commented on GitHub (Feb 11, 2019): Yes, it was the missing "ugc-image-upload" scope. I knew that once, but forgot it ... many thanks for the hint! Cheers, Christian
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/spotify-web-api-php#95
No description provided.