Announcements

Help Wizard

Step 1

NEXT STEP

Error 400 when trying to reach the 'Custom Playlist Cover Image' endpoint

Error 400 when trying to reach the 'Custom Playlist Cover Image' endpoint

I have a problem with Web API in my Flutter app. I'm trying to change the image of a playlist with the 'Custom Playlist Cover Image' endpoint. My request is in the next reply.
Reply
1 Reply

var byteData = await rootBundle.load('assets/images/playlist_icon.jpg');
    var buffer = byteData.buffer.asUint8List();
    /*String base64Encode = base64
        .encode(buffer)
        .replaceAll('+', '-')
        .replaceAll('/', '_')
        .replaceAll('=', '');*/
    String base64Encode = base64.encode(buffer);
    //dev.log(jsonEncode(base64Encode).toString());
    //dev.log(base64Encode);
    //the request should contain a Base64 encoded JPEG image data, maximum payload size is 256 KB
    url = Uri.https('api.spotify.com', 'v1/playlists/$idPlaylist/images');
    _setResponse(await _client.put(url,
        headers: <String, String>{
          'Accept': 'application/json',
          'Authorization': '$_tokenType $token',
          'Content-Type': 'image/jpeg'
        },
        body: base64Encode));
    decodedResponse = jsonDecode(utf8.decode(_response.bodyBytes)) as Map;
    dev.log(decodedResponse.toString());

Suggested posts

Let's introduce ourselves!

Hey there you,   Yeah, you! 😁   Welcome - we're glad you joined the Spotify Community!   While you here, let's have a fun game and get…

ModeratorStaff / Moderator/ 4 years ago  in Social & Random