【发布时间】:2017-03-15 21:29:38
【问题描述】:
我正在尝试使用 Spotify API 创建播放列表,但收到以下错误:
{
"error" : {
"status" : 400,
"message" : "Error parsing JSON."
}
}
我正在关注example on this page,它说要使用以下 curl 请求
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);
}
});
谁能告诉我我做错了什么?
【问题讨论】:
-
再次检查您的令牌,ajax 是否正确
-
@HudsonPH 我不认为令牌有问题,因为我可以发出其他请求,只是 POST 请求吸引了我
标签: javascript jquery rest spotify