python - 在邮递员 API 中更改用户名和密码
问题描述
我在邮递员中运行了一个 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)
当我在邮递员中检查 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 用户名和密码(我通过了授权),但我无法在 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>
解决方案
您应该将包含用户名和密码的 json 字符串放在以下框中: 然后单击 python 中的代码,它将显示正确的代码,如下所示:
与套装相同
payload = "{\"username\": \"\",\"password\": \"xxxxxx\",\"remeber\":0}"
推荐阅读
- node.js - 我如何同时为不同的项目运行 npm install
- xcode10 - Xcode 10 说团队没有 App Store 连接访问权限,应用程序加载器说没有 CFbundle ID
- netflix-zuul - 当有大数据要从另一个微服务接收时,Zuul 抛出异常
- machine-learning - 特征选择技术
- c# - 如何开发最佳解析器方案?
- continuous-integration - Gitlab-CI 多项目管道
- javascript - 试图用 pugjs 和 momentjs 做一个 timeleft
- entity-framework - 从对基类的请求中排除派生实体
- python-3.x - AWS sagemaker 上的 LightFM | 是否可以训练模型
- microsoft-graph-api - O365 订阅续订引发未知异常