@@ -186,9 +186,16 @@ public void createPlaylist(String webToken, String playlistName, Bitmap cover, b
186
186
byte [] byteArr = stream .toByteArray ();
187
187
String base64Cover = Base64 .encodeToString (byteArr , Base64 .NO_WRAP );
188
188
base64Cover = base64Cover .trim ().replace ("\n " , "" );
189
-
189
+ String bodyContent ;
190
+ if (isCollaborative ) {
191
+ if (isPublic ) {
192
+ Log .w ("Spotify API" , "Collaborative playlists can only be private." );
193
+ }
194
+ bodyContent = "{\n \" name\" :\" " + playlistName + "\" ,\n \" public\" :" + false + ",\n \" collaborative\" :" + true + "\n }" ;
195
+ } else {
196
+ bodyContent = "{\n \" name\" :\" " + playlistName + "\" ,\n \" public\" :" + isPublic + ",\n \" collaborative\" :" + false + "\n }" ;
197
+ }
190
198
MediaType mediaType = MediaType .parse ("application/json" );
191
- String bodyContent = "{\n \" name\" :\" " + playlistName + "\" ,\n \" public\" :" + isPublic + ",\n \" collaborative\" :" + isCollaborative + "\n }" ;
192
199
RequestBody body = RequestBody .create (mediaType , bodyContent );
193
200
Log .e ("SpotifyUtil" , "Creating Playlist: " + bodyContent );
194
201
Request request = new Request .Builder ()
@@ -219,6 +226,7 @@ public void createPlaylist(String webToken, String playlistName, Bitmap cover, b
219
226
// Extract the playlist ID from the response
220
227
String responseBody = response .body ().string ();
221
228
JSONObject jsonResponse = new JSONObject (responseBody );
229
+ Log .w ("SpotifyUtil" , jsonResponse .toString ());
222
230
String playlistUri = jsonResponse .getString ("uri" );
223
231
String playlistId = playlistUri .split (":" )[2 ];
224
232
0 commit comments