我正在尝试使用带有restconf的python脚本在路由器中激活OSPF路由协议。我将请求发送到此 url https://(routerip)/restconf/data/Cisco-IOS-XE-ospf-native-router:10 但我收到此返回消息:{"errors":{"error":[{"error-message":"uri keypath not found ", "错误标签": "无效值", "错误类型": "应用程序"} ] } }
我尝试了不同的网址,但没有一个是正确的,我不知道什么是错的,网址或正文的内容,有人可以帮助我吗?
这是我的脚本的内容:
import json
import requests
requests.packages.urllib3.disable_warnings()
api_url = "https://(ip)/restconf/data/Cisco-IOS-XE-ospf-native-router:10"
headers = {"Accept": "application/yang-data+json",
"Content-type": "application/yang-data+json"}
basicauth = ("user", "password")
body = '{"router":{"ospf":[{"id":10, "router-id":"1.1.1.1", "network":[{"ip": "172.16.199.1", "mask": "0.0.0.0", "area": 0},{"ip":"192.168.56.101", "mask": "0.0.0.0", "area":0}]}]}}'
requests.put(api_url, auth=basicauth, headers=headers, data=body, verify=False)
resp = requests.get(api_url, auth=basicauth, headers=headers, verify=False)
response_json = resp.json()
print(json.dumps(response_json, indent=5))