且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Python 放置请求.Spotify API 放置请求格式错误的 Json

更新时间:2022-01-28 07:34:18

07bYtmE3bPsLB6ZbmmFi8d:此 Spotify id 适用于专辑 Dancefloor Hits #1.我检查了我的 Spotify 帐户,它在我帐户的相册中.下面是我运行它的代码.

07bYtmE3bPsLB6ZbmmFi8d: This spotify id is for the album, Dancefloor Hits #1. I checked my spotify acct and there it was in my Albums on my acct. Below is my code to run that.

import requests

url = "https://api.spotify.com/v1/me/albums"

payload = {"ids": "27cZdqrQiKt3IT00338dws"}
headers = {
  'Content-Type': 'application/json',
  'Authorization': 'Bearer %s' % (access_token) # paste your access token in here
}

''' you can use the same syntax as above but the key was that your ID of album had to be a **parameter** not ***data***. 
To do that you use the params kwarg'''

response = requests.request("PUT", url, headers=headers, params = payload)

print(response.status_code) # should print out 200 when you run the code
# shows whether status was valid