创建播放列表spotify API
create playlist spotify API
我正在尝试使用Spotify API创建一个播放列表,并收到以下错误:
{
"error" : {
"status" : 400,
"message" : "Error parsing JSON."
}
}
我遵循这个页面上的例子,说要使用以下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);
}
});
谁能告诉我做错了什么?
原因是我没有发布有效的儿子。通过使用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);
}
});
相关文章:
- Spotify API:获取随机歌曲
- 获取 Spotify 用户 [Web API] 当前播放的曲目名称
- 如何使用Spotify应用程序API制作大型专辑播放器
- 使用播放按钮和/或元数据API(Spotify)进行现场演示
- 使用 Meteor HTTP 在 Spotify API 上请求access_token时不受支持的授权类型错误
- 开始使用 Spotify API(适用于 Web App)
- 我正在制作我的作品集,我想使用 Spotify API 来显示我当前正在收听的内容,但不想使用“播放”按钮
- 从Spotify API获取乐队名称搜索结果
- 为 API 调用返回未定义的数组(Spotify 应用程序)
- Spotify Api,位置属性错误
- Spotify Local Server API
- 通过Web API或libspotify获取Spotify的播放历史记录
- SPOTIFY APP API:向播放列表项.sp-item/更改views.js中的item_HEIGHT属性添加填充
- 通过Spotify应用程序API打开自定义url方案
- Spotify应用程序API:检测离线模式
- Spotify API-创建临时播放列表
- 使用Spotify API插件专辑名称和歌手名称搜索曲目
- Spotify API-从临时播放列表中删除所有曲目
- Spotify API-获取播放列表中每个曲目的曲目URI
- 我可以用Spotify API听一些活动吗,比如歌曲结尾