我正在尝试调用一个在Postman上运行的帖子请求,但返回的代码是400。这是我的尝试:
url = "http://192.168.9.194:7780/xtv-ws-client/api/login/auth?
accountid=342&password=3534"
headers = {"Content-Type": "application/x-www-form-urlencoded"}
rsp = requests.post(url, headers=headers)
print (rsp.status_code)
和
url = "http://192.168.9.194:7780/xtv-ws-client/api/login/auth"
Body1 = {
"accountid": "342",
"password": "3534"
}
headers = {"Content-Type": "application/x-www-form-urlencoded"}
rsp = requests.post(url, json=Body1, headers=headers)
print (rsp.status_code)
和
params = {'accountid': '342', 'password': '3534'}
url = "http://192.168.9.194:7780/xtv-ws-client/api/login/auth?
accountid=342&password=3534"
headers = {"Content-Type": "application/x-www-form-urlencoded"}
rsp = requests.post(url, headers=headers, params = params)
print (rsp.status_code)
答案 0 :(得分:1)
params = {'accountid': '342', 'password': '3534'}
url = "http://192.168.9.194:7780/xtv-ws-client/api/login/auth"
rsp = requests.post(url, data=params)
print (rsp.status_code)