400仅支持有效的承载validation – Spotify API

我正在使用Spotify API(特别是https://api.spotify.com/v1/recommendations上的build议端点),我一直收到状态码400,并显示消息“仅支持有效承载身份validation”。 这里是相关的代码片段:

let token = body.access_token; //gives access token let token_type = body.token_type; //gives the string 'Bearer' let options = { url: 'https://api.spotify.com/v1/recommendations?' + querystring.stringify({ min_danceability: 1.0, min_energy: 0.5 }), //Formats the header as {Authorization: Bearer {token}} headers: {'Authorization': `${token_type} ${token}`}, json: true }; request(options, (error,response,body) =>{ if (!error && response.statusCode === 200) { console.log(body); } else { //This always seems to console.log statusCode 400 console.log(response.statusCode); } }); 

编辑:任何人谁发现这个职位,我想通了。 在使用build议端点时,您必须至less包含seed_genres,seed_artists或seed_tracks之一。 否则,端点将继续返回400仅有效承载validation支持错误。