我正在尝试使用Spotify Web API在传递曲目ID时播放曲目。我在Spotify的API控制台here上使用PUT https://api.spotify.com/v1/me/player/play
端点。当我在PUT
Body中使用示例数据,并添加我的设备ID和OAuth令牌abd时,单击“尝试”按钮,歌曲开始播放。当我将PUT
Body更改为:
{
"context_uri": "spotify:track:4ByEFOBuLXpCqvO1kw8Wdm"
}
我收到错误:
HTTP/1.1 400 Bad Request
Content-Length: 99
Access-Control-Allow-Methods: GET, POST, OPTIONS, PUT, DELETE, PATCH
Access-Control-Max-Age: 604800
Access-Control-Allow-Credentials: true
Content-Encoding: gzip
Keep-Alive: timeout=600
Server: nginx
Connection: keep-alive
Cache-Control: private, max-age=0
Date: Wed, 31 Jan 2018 00:56:54 GMT
Access-Control-Allow-Origin: *
Access-Control-Allow-Headers: Accept, Authorization, Origin, Content-Type, Retry-After
Content-Type: application/json; charset=utf-8
{
"error" : {
"status" : 400,
"message" : "Non supported context uri"
}
}
关于它为什么不起作用的任何想法?
答案 0 :(得分:1)
如果您查看Spotify的API,track
不支持context_uri
。
Optional. Spotify URI of the context to play.
Valid contexts are albums, artists & playlists.
Example: {context_uri:"spotify:album:1Je1IMUlBXcx1Fz0WE7oPT"}
https://developer.spotify.com/web-api/start-a-users-playback/
答案 1 :(得分:0)
如果你通过:
{
"uris": ["spotify:track:4ByEFOBuLXpCqvO1kw8Wdm"]
}
它会起作用。您也可以,然后在uris
列表中传递多首歌曲。