Syntax error due to = in your headers dictionary:
headers = {'Authorization': 'Bearer ' + token, "Content-Type": "application/json", data=data}
It should be:
headers = {'Authorization': 'Bearer ' + token, "Content-Type": "application/json", 'data':data}
See data=data changed using 'data':data . Colon and Single Quotes.
And are you sure you will send data to your headers? Or should you replace payload with data in the put request?
Edit:
As you edited the question, and now you send the data as the request body PUT requests.put(data=data) , so there is no need for headers. Just change the headers to:
headers = {'Authorization': 'Bearer ' + token, "Content-Type": "application/json"}
But since you set the Content-Type header to application/json , so I think in the PUT request you should do
response = requests.put(url, data=json.dumps(data), headers=headers)
which sends your data as json.
source share