使用 python post 请求添加新设备时,数据包跟踪器网络控制器中出现错误 500

时间:2021-04-24 07:19:51

标签: python api rest http cisco

我实际上正在研究我的最后一年项目(第二个硕士学位学生)我在尝试发送 post 请求以将设备添加到我的网络时遇到此错误,网络配置工作 100% 我之前做过一个 get 请求,它效果很好,这周我需要它,请帮忙,谢谢。

import requests
import json
baseUri = "http://127.0.0.1:58000/api/v1"


#API call to request service ticket
headers = {"Content-type":"application/json"}
data = json.dumps({"username" : "admin" , "password": "admin123"})
resp = requests.post(baseUri +"/ticket", data=data, headers=headers)

#print(resp.status_code)
result = resp.json()
#print(result)

ticket = result["response"]["serviceTicket"]
print(ticket)


#Post request to add R4 to the monitoring
headers = {"X-Auth-Token": ticket }
data = json.dumps({"globalCredentialId:": "252e76da-3603-4c03-8977-d2181ad00b66 ","ipAddress:" : "192.168.3.2"})
resp = requests.post(baseUri +"/network-device", data=data, headers=headers)

print(resp.status_code)
result = resp.json()
print(result)

0 个答案:

没有答案