Announcements

Help Wizard

Step 1

NEXT STEP

Creating playlist endpoint returning "Missing required filed name: name"

Creating playlist endpoint returning "Missing required filed name: name"

Currently creating an app that uses the spotify web api to create a playlist for the user. The app runs everything server side, auth works well, but the endpoint:

 

https://api.spotify.com/v1/users/{user_id}/playlists 

 

gives me the error: { error: { status: 400, message: 'Missing required field: name' } }

 

This is a code snippet that I am using to generate the playlist

 

 

 

 

 

 

 

 

const BASE_URL = "https://api.spotify.com/v1";

const createPlaylistParams = new URLSearchParams({
      name: playlistName,
    }).toString();

const createPlaylistReponse = await fetch(
     `${BASE_URL}/users/${currentUser.id}/playlists${createPlaylistParams}`,
      {
        method: "POST",
        headers: {
          Authorization: `Bearer ${access_token}`,
        },
      }
    );

 

 

 

 

 

 

 

 

Any help and advice would be greatly appreciated.

Reply
1 Reply

Hello,

 

I'm not sure the JS equivalent, but changing my Python requests.post() parameter from data to json did the trick.

 

(from a superficial Google search I'd assume your solution is something like swap your new URLSearchParams() with JSON.stringify(), but I'm not confident)

 

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