首页 > 解决方案 > 在邮递员 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>

标签: pythonapipostman

解决方案


您应该将包含用户名和密码的 json 字符串放在以下框中:这里 然后单击 python 中的代码,它将显示正确的代码,如下所示: 这里

与套装相同

payload = "{\"username\": \"\",\"password\": \"xxxxxx\",\"remeber\":0}"

推荐阅读