[英]create playlist spotify API
我正在尝试使用Spotify API创建播放列表,并收到以下错误:
{
"error" : {
"status" : 400,
"message" : "Error parsing JSON."
}
}
curl -X POST "https://api.spotify.com/v1/users/thelinmichael/playlists" -H "Authorization: Bearer {your access token}" -H "Content-Type: application/json" --data "{\"name\":\"A New Playlist\", \"public\":false}"
我的代码看起来像这样
$.ajax({
url: 'https://api.spotify.com/v1/users/{id}/playlists',
method: "POST",
data: {
name: "test"
},
headers: {
'Authorization': 'Bearer ' + access_token,
'Content-Type': 'application/json'
},
success: function(response) {
console.log(response);
}
});
谁能告诉我我做错了什么?
原因是我没有张贴有效的儿子。 通过使用JSON.stringify
我能够解决这个问题。
JSON.stringify({name: "test", public: false})
完整代码如下所示:
$.ajax({
url: 'https://api.spotify.com/v1/users/{id}/playlists',
method: "POST",
data: {
name: JSON.stringify({name: "test", public: false})
},
headers: {
'Authorization': 'Bearer ' + access_token,
'Content-Type': 'application/json'
},
success: function(response) {
console.log(response);
}
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.