I try to post some data on the website, and it runs perfectly when I run on Pycharm. But when I try on Postman it still gets OK(200) but I don’t get my JSON data. Here is my code
import requests
import json
with open('input.json','r') as f:
file_data = json.load(f)
r = requests.get("https://httpbin.org/get", data=file_data)
print(r.text)
I want to double-check that my data has been posted on both sides.
1
This code works for me. I just replaced null
to None
:
import requests
data = {
"args": {},
"data": "",
"files": {},
"form": {
"a": "1",
"id": "123",
"model": "a12",
"name": "John",
"number": "456",
"status": "OK"
},
"headers": {
"Accept": "*/*",
"Accept-Encoding": "gzip, deflate",
"Content-Length": "51",
"Content-Type": "application/x-www-form-urlencoded",
"Host": "httpbin.org",
"User-Agent": "python-requests/2.32.3",
"X-Amzn-Trace-Id": "Root=1-66d82479-64115df475c1d2fc14803b3c"
},
"json": None,
"origin": "117.0.114.106",
"url": "https://httpbin.org/post"
}
r = requests.get("https://httpbin.org/get", data=data)
print(r.text)