我在postman中运行了一个API,它运行得很好。代码如下:
import requests
url = 'https://sct.intutrack.com/api/prod/login'
payload = {}
headers = {}
response = requests.request('POST', url, headers = headers, data = payload, allow_redirects=False, timeout=undefined, allow_redirects=false)
print(response.text)当我检查postman中的python代码时,它给出了以下信息:
import requests
url = "https://sct.intutrack.com/api/prod/login"
payload = ""
headers = {
'Content-Type': "application/json",
'User-Agent': "PostmanRuntime/7.15.0",
'Accept': "*/*",
'Cache-Control': "no-cache",
'Postman-Token': "33e50c20-f264-4b65-8fc8-7016b3315134,8b5414b1-4b79-4749-91d7-80daa4d4ecbe",
'Host': "sct.intutrack.com",
'accept-encoding': "gzip, deflate",
'content-length': "",
'Connection': "keep-alive",
'cache-control': "no-cache"
}
response = requests.request("POST", url, data=payload, headers=headers)
print(response.text)我有一个API用户名和密码(我在Authorization中传递了),但我无法在python代码中找到相同的用户名和密码。我如何才能更改它们?
Jupyter Notebook的结果:
<html>
<head><title>400 Bad Request</title></head>
<body bgcolor="white">
<center><h1>400 Bad Request</h1></center>
<hr><center>nginx</center>
</body>
</html>发布于 2019-06-24 17:43:47
您应该在以下框中输入包含用户名和密码的json字符串:

然后单击python中的代码,它将显示正确的代码,如下所示:

与SET相同
payload = "{\"username\": \"\",\"password\": \"xxxxxx\",\"remeber\":0}"https://stackoverflow.com/questions/56733588
复制相似问题