簡體   English   中英

錯誤400錯誤請求Spotify API發布請求

[英]Error 400 Bad Request Spotify API Post Request

我正在開發一個Web應用程序,用戶可以搜索音樂,創建新的播放列表,然后將其保存到他們的Spotify帳戶中。 我目前堅持在用戶Spotify上創建新的播放列表。

    `        //userUd, playlistName, currentUserAccessToken are all defined 

fetch(`https://api.spotify.com/v1/users/${userId}/playlists`, {
              headers: {
                'Authorization': 'Bearer ' + currentUserAccessToken
              },
              contentType: 'application/json',
              method: 'POST',
              body: {
                "name": `${playlistName}`,
                "description": `You made this playlist with Jammming, a ReactJS web application built by Max Page`
              }
            }).then(playlist => {
              console.log(playlist);
              return playlist.json();
            }).catch(err => {
              console.log(err);
            })`

這里的目標是獲取新的playlistId,有人對為什么Im收到400 Bad Request錯誤有任何想法嗎? 我執行了GET請求來授權用戶-包括創建公共播放列表的范圍,在可以正常工作的其他代碼塊中,這是:

`let scopes = 'playlist-modify-public';

 window.location.replace(`https://accounts.spotify.com/authorize?client_id=${clientID}&scope=${scopes}&redirect_uri=${redirectURI}&response_type=token`);`

提前致謝!

使你的身體變得整齊。 那就是為我修復相同錯誤的原因

fetch(`https://api.spotify.com/v1/users/${userId}/playlists`, {
          headers: {
            'Authorization': 'Bearer ' + currentUserAccessToken
          },
          contentType: 'application/json',
          method: 'POST',
          body: JSON.stringify({
            "name": `${playlistName}`,
            "description": `You made this playlist with Jammming, a ReactJS web application built by Max Page`
          })
        }).then(playlist => {
          console.log(playlist);
          return playlist.json();
        }).catch(err => {
          console.log(err);
        })`

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM