Answer the question
In order to leave comments, you need to log in
PUT request works in Curl, why doesn't it work in Python3?
I try the PUT method in curl and in python, but the result is different.
We need to enable the enabled checkbox on the server.
this is how it works, code 200, enabled=True
curl --user user:pass
-X PUT "https://api.url/27"
-H "Accept: application/json" -H "Content-Type: application/json" -H "Token: token"
-d "{ \"enabled\": true}"
headers = {
'Accept': 'application/json',
'Content-type': 'application/json',
'Token': 'token'
}
auth = ('user', 'pass')
def enabled_settings(order_id):
enabled = True
data = {"enabled": enabled}
res = requests.put(f'api.url/{order_id}',
data=data,
headers=headers,
auth=auth)
return res.json()
Answer the question
In order to leave comments, you need to log in
Try like this:
...
res = requests.put(f'{api.url/{order_id}',
json=data,
headers=headers,
auth=auth)
...
Is the line written correctly in the source code?
And if so?
f'{api.url/{order_id}'
requests.put(f'{api.url/{order_id}',
json=data,
headers=headers,
auth=auth)
payload="{\"enabled\": true}"
requests.put(f'{api.url/{order_id}',
data=payload,
headers=headers,
auth=auth)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question