05-09-2018 07:20 AM - edited 03-01-2019 04:09 AM
Hi,
I tried to post a request with different types of payload, but no luck.
Anyone can help me on it.
Header 1 | Header 2 |
---|---|
curl -X POST -H 'content-type: application/vnd.yang.data+json' http://xxxxxxx@x.x.x.x:8080/ api/running/devices/device/SJC02-WXLB-PE01/config/cisco-ios-xr:event/manager/environment/ -d '{"name": "n1", "var-value": "v1"}' | {"errors": {"error": [{"error-message": "POST on list must be on list element", "error-urlpath": "/api/running/devices/device/SJC02-WXLB-PE01/config/cisco-ios-xr:event/manager/environment", "error-tag": "malformed-message"}]}} |
curl -X POST -H 'content-type: application/vnd.yang.data+json' http://xxxxxxx@x.x.x.x:8080/api/running/devices/device/SJC02-WXLB-PE01/config/cisco-ios-xr:event/manager/environment/n1 -d '{"var-value": "v1"}' | {"errors": {"error": [{"error-message": "post to a nonexistent list resource", "error-urlpath": "/api/running/devices/device/SJC02-WXLB-PE01/config/cisco-ios-xr:event/manager/environment/n1", "error-tag": "malformed-message"}]}} |
Thanks in advance.
Solved! Go to Solution.
05-09-2018 07:39 AM
Have you tried PUT?
Please note the key "MyNSInfo" in both that PATH and in the payload.
This pattern works for me:
curl -X PUT \
http://localhost:8080/api/running/nfvo/ns-info/esc/ns-info/MyNSInfo \
-H 'Authorization: Basic YWRtaW46YWRtaW4=' \
-H 'Content-Type: application/vnd.yang.data+json' \
-d '{
"tailf-etsi-rel2-nfvo-esc:ns-info": {
"id": "MyNSInfo",
"tenant": "volvo",
"deployment-name": "MyDeployment",
"esc": "esc0",
"username": "admin",
"nsd": "fw-router",
"flavor": "fw-router-flavor",
"instantiation-level": "small",
"vnf-info": [
{
"vnf-profile": "ASA",
"vnfd": "ASA",
"vdu": [
{
"id": "firewall",
"managed": [
null
],
"bootup-time": 120,
"recovery-wait-time": 120,
"image-name": "ASA-9.3.1",
"flavor-name": "m1.large",
"day0": [
{
"destination": "day0-config",
"url": "http://localhost:4545/day0/ASA_941_day0.txt"
}
],
"authgroup": "default"
}
]
},
{
"vnf-profile": "CSR1kv",
"vnfd": "CSR1kv",
"vdu": [
{
"id": "CSR",
"managed": [
null
],
"bootup-time": 300,
"recovery-wait-time": 200,
"image-name": "CSR-3.17.3",
"flavor-name": "CSR",
"day0": [
{
"destination": "iosxe_config.txt",
"url": "http://localhost:4545/day0/CSR_day0.txt"
}
],
"authgroup": "default"
}
]
}
],
"virtual-link-info": [
{
"virtual-link-descriptor": "inside-net",
"subnet": {
"network": "192.168.1.0/30"
}
}
],
"sap-info": [
{
"sapd": "outside",
"network-name": "CiscoInternet"
},
{
"sapd": "inside",
"network-name": "CiscoLAN"
},
{
"sapd": "mgmt",
"network-name": "mgmt"
}
],
"state": "not-instantiated"
}
}'
05-09-2018 07:39 AM
Have you tried PUT?
Please note the key "MyNSInfo" in both that PATH and in the payload.
This pattern works for me:
curl -X PUT \
http://localhost:8080/api/running/nfvo/ns-info/esc/ns-info/MyNSInfo \
-H 'Authorization: Basic YWRtaW46YWRtaW4=' \
-H 'Content-Type: application/vnd.yang.data+json' \
-d '{
"tailf-etsi-rel2-nfvo-esc:ns-info": {
"id": "MyNSInfo",
"tenant": "volvo",
"deployment-name": "MyDeployment",
"esc": "esc0",
"username": "admin",
"nsd": "fw-router",
"flavor": "fw-router-flavor",
"instantiation-level": "small",
"vnf-info": [
{
"vnf-profile": "ASA",
"vnfd": "ASA",
"vdu": [
{
"id": "firewall",
"managed": [
null
],
"bootup-time": 120,
"recovery-wait-time": 120,
"image-name": "ASA-9.3.1",
"flavor-name": "m1.large",
"day0": [
{
"destination": "day0-config",
"url": "http://localhost:4545/day0/ASA_941_day0.txt"
}
],
"authgroup": "default"
}
]
},
{
"vnf-profile": "CSR1kv",
"vnfd": "CSR1kv",
"vdu": [
{
"id": "CSR",
"managed": [
null
],
"bootup-time": 300,
"recovery-wait-time": 200,
"image-name": "CSR-3.17.3",
"flavor-name": "CSR",
"day0": [
{
"destination": "iosxe_config.txt",
"url": "http://localhost:4545/day0/CSR_day0.txt"
}
],
"authgroup": "default"
}
]
}
],
"virtual-link-info": [
{
"virtual-link-descriptor": "inside-net",
"subnet": {
"network": "192.168.1.0/30"
}
}
],
"sap-info": [
{
"sapd": "outside",
"network-name": "CiscoInternet"
},
{
"sapd": "inside",
"network-name": "CiscoLAN"
},
{
"sapd": "mgmt",
"network-name": "mgmt"
}
],
"state": "not-instantiated"
}
}'
05-09-2018 10:22 AM
I'd also recommend that you start using the RESTCONF API (over the REST API).
05-09-2018 04:18 PM
Thank Fredrik very much.
You reminded me I should use PATCH method instead of POST, and it works now.
By the way, currently we are working on NSO 4.3.1, is it support RESTCONF API? the advantage over REST API is performance or something else?
thanks again.
05-14-2018 02:42 PM
I'd say the biggest advantage is that RESTCONF is standardized.
05-14-2018 08:06 PM
REST vs RESTCONF
Also, I believe Tail-f development has capped any new features for REST interface.
RESTCONF interface will continue to be enhanced moving forward.
-Larry
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide