Help Wizard

Step 1

NEXT STEP

Trouble with Create Playlist

Solved!

Trouble with Create Playlist

Plan

Premium

Country

US
Device

Node
Operating System

Macos

My Question or Issue

Today I set off to build a Spotify app. Everything was going swimmingly till I hit the createPlaylist endpoint. 

I can log in and retrieve an access token, from there I am able to query for the user and get the user's id. I can list tracks in a playlist, but what I can't do is create a playlist. Any help would be awesome.

 

 

 

 

 

 

export const createPlaylist = async (accessToken, userId, playlistName) => {
  const url = `https://api.spotify.com/v1/users/${userId}/playlists`;
  console.log(url);
  const headers = { Authorization: `Bearer ${accessToken}`, 'Content-Type': 'application/json' };
  const data = { name: playlistName, public: "false" };
  try {
    const response = await axios.post(url, data, { headers });
    return response.data;  // Assuming it returns the created playlist details
  } catch (error) {
    console.error('\n\nError creating playlist:\n', error);
    return null;
  }
};

 

 

 

 

 

 

 
Reply

Accepted Solutions
Marked as solution

Do you have used the right scopes? You can find them at the top of each endpoint reference page.

View solution in original post

2 Replies
Marked as solution

Do you have used the right scopes? You can find them at the top of each endpoint reference page.

Playlist creation worked fine for me until today.

Now, I have a 502 error.

I have it even when trying to create a playlist from here https://developer.spotify.com/documentation/web-api/reference/create-playlist

Suggested posts