无法使用 python 查看请求输出

无法使用 python 查看请求输出

我正在学习 Python 并开发一个简单的 rest 客户端,以便从 Web 服务器检索库存数据。我通过了身份验证步骤(检索 TGT&ST 票证并收到登录成功)。之后,我想运行一些库存请求,它只显示一个 http 模板...当我在 Postman 中运行此代码时,它可以正常工作。我甚至从 Postman 复制粘贴代码片段,但仍然没有给我正确的文本。

由于建立了安全通信,我不得不避免 SSL 验证,但我想这并不重要。

url = "https://xxx.xx.xx.xx:8443/oms1350/data/otn/networkElement"
payload = ""
headers = {
'Content-Type': "application/x-www-form-urlencoded",
'cache-control': "no-cache",
'Accept': "application/json"
}
response = requests.request("GET", url, data=payload, headers=headers, verify = False)
print(response.stats_code)
print(response.text)

但是,输出不是数据。看起来像一个网页模板:

输出截图

我尝试用邮递员发出相同的请求,它显示的信息:

{"reqCompletionStatus":0,"requestId":0,"clientName":null,"clientLocation":null,"clientUser":null,"sessionId":"","mdcId":null,"sequenceNum":0,"moreToCome":false,"messages":[],"errcde":null,"errorParams":null,"nextTasks":null,"items":[{"className":"networkElement","id":"4289","key":"networkElement/4289","guiLabel":"TEST_tn_34_extn_VNE1","NeId":"4289","NeName":"TEST_tn_34_extn_VNE1","NeType":"BBOX_NE","compositeNodeName":"TEST_tn_34_extn_VNE1","activityState":"activitystate.15","commsStatus":"CS_DOWN","managementType":"NMT_UNKNOWN","configDownloadStatus":"DownloadDisabled","swVersion":"R1.0","nprNeId":"1594","neModel":"BBOX_NE","controllerModel":"NPR","controllerName":"OTNE_2_NPR","controllerSwVersion":"R1.0","neName

我怎样才能在 python shell 中看到相同的输出?提前感谢您的帮助。

问候,Volkan

相关内容