I am trying to update metadata for an existing playlist using web API's. In the code, below using: requests.put
returns [400] as a response suggesting a bad request. I have also tried requests.post
however, this returns[405]
as the error code.
Can anyone spot if I have a syntax error? of is there some other issue I can't see?
note: I have had success retrieving data from the playlist using: get
It just seems to be editing the details that is the issue.
Thanks for your help.
def update_metadata(access_token, playlist_id, playlist_name, playlist_description):
playlist_endpoint = f"https://api.spotify.com/v1/playlists/{playlist_id}"
metadata = {
"name": 'playlist title', "description": 'TEST', "public": True
}
get_headers = {
"Accept": "application/json",
"Content-Type": "application/json",
"Authorization": f"Bearer {access_token}"
}
res = requests.put(playlist_endpoint, headers=get_headers, data=metadata)
print(res)
return res
Useful Links:
Error codes: https://developer.spotify.com/documentation/web-api/
Change playlist details: https://developer.spotify.com/console/put-playlist/