如何将 uris 添加到 javascript 中的 post 请求
How to add uris to post request in javascript
我似乎无法弄清楚如何将 uris 添加到 post 请求,例如 api 请求:https://developer.spotify.com/console/post-playlist-tracks/?playlist_id=3cEYpjA9oz9GiPac4AsH4n&position=&uris=spotify%3Atrack%3A4iV5W9uYEdYUVa79Axb7Rh%2Cspotify%3Atrack%3A1301WleyT98MSxVHPZCA6M
这就是我的请求目前看起来不起作用
fetch(endPoint, {
method: "POST",
headers: {
Authorization: `Bearer ${access_token}`,
},
body: JSON.stringify({
"uri": data
})
});
提前感谢您的帮助
基于此文档:https://developer.spotify.com/documentation/web-api/reference/#/operations/add-tracks-to-playlist
看来您的正文格式有误。它应该看起来像这样:
fetch(endPoint, {
method: "POST",
headers: {
Authorization: `Bearer ${access_token}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
uris: [
"uri-1",
"uri-2",
],
})
});
我似乎无法弄清楚如何将 uris 添加到 post 请求,例如 api 请求:https://developer.spotify.com/console/post-playlist-tracks/?playlist_id=3cEYpjA9oz9GiPac4AsH4n&position=&uris=spotify%3Atrack%3A4iV5W9uYEdYUVa79Axb7Rh%2Cspotify%3Atrack%3A1301WleyT98MSxVHPZCA6M
这就是我的请求目前看起来不起作用
fetch(endPoint, {
method: "POST",
headers: {
Authorization: `Bearer ${access_token}`,
},
body: JSON.stringify({
"uri": data
})
});
提前感谢您的帮助
基于此文档:https://developer.spotify.com/documentation/web-api/reference/#/operations/add-tracks-to-playlist
看来您的正文格式有误。它应该看起来像这样:
fetch(endPoint, {
method: "POST",
headers: {
Authorization: `Bearer ${access_token}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
uris: [
"uri-1",
"uri-2",
],
})
});