0
votes

I am working on Spotify on node, when I try to create a playlist, it keep return

{ error: { status: 400, message: 'Error parsing JSON.' } }

function create_playlist(user_id,access_token){
    var options = {
        url: "https://api.spotify.com/v1/users/"+user_id+"/playlists",
        data: { 'Authorization': 'Bearer ' + access_token},
        json : true,
        headers: {
            'Authorization': 'Bearer ' + access_token
        },
        "content-Type": 'application/json'
      };   

      request.post(options,(error,response,body) => {
          console.log(body);
      })

I do have the right scope const SCOPE = 'playlist-modify-public'

1

1 Answers

2
votes

See this other StackOverflow post:

require.js POST request to spotify web api returning "Error parsing json"

It says you should be using body instead of data, also you should call JSON.stringify()