I'm a little bit new coding. I have an API that works perfectly sending the request from browser but when I try to run it with python requests it returns json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
This is a part of my API:
post_data = json.loads(request.body.getvalue().decode('utf-8'))
run = postdata['run']
response = postdata['response']
and my requests with python is:
payload = {"run":1, "response" : "https://sampleserver"}
headers = {"content-type" : "application/json"}
r = requests.post("http://myserver", data = payload, headers = headers)
I think that maybe the problem is in the post_data
requests.post()
in the second. What isrequest.body
in the first? – quamranapost_data = r.json()
– furasr.text
(orrequest.body.getvalue()
) to see you didn't get some HTML with explanation. – furas