07-22-2020 02:09 PM
Hi All,
I created a service into NSO. The Yang of the service is:
module QoS_SELF-HEALING { namespace "http://com/example/QoS_SELFHEALING"; prefix QoS_SELF-HEALING; import ietf-inet-types { prefix inet; } import tailf-ncs { prefix ncs; } augment /ncs:services { list QoS_SELF-HEALING { key name; uses ncs:service-data; ncs:servicepoint "QoS_SELF-HEALING"; leaf name { type string; } leaf device { type leafref { path "/ncs:devices/ncs:device/ncs:name"; } } leaf interface { type string; } } } }
Executing the service by the CLI interface, everthing runs well. But when I tried call the service using Postman, I got an error!
The Postman call is:
curl --location --request POST'http://172.26.4.193:8080/restconf/data/services/QoS_SELF-HEALING' \ --header 'Content-Type: application/yang-data+json' \ --header 'Accept: application/yang-data+json' \ --header 'Authorization: Basic cm9vdDpjaXNjbzEyMw==' \ --data '{ "QoS_SELF-HEALING:QoS_SELF-HEALING": { "name" : "SRVACR", "device" : "RMC01", "interface" : "0/0/0/2" } }'
The error gotten:
{ "errors": { "error": [ { "error-message": "POST on list must be on list element", "error-path": "/tailf-ncs:services/QoS_SELF-HEALING:QoS_SELF-HEALING", "error-tag": "malformed-message", "error-type": "application" } ] } }
If I change the method to PATCH, the API call runs properly. So I don't know what I'm doing wrong.
Thanks in advance,
lnunesdo
Solved! Go to Solution.
07-22-2020 02:34 PM
Hi lnunesdo,
You are real close.
I think if you just need remove the service name Qos_SELF_HEALING from the URI (stop at services) in your Post request and use the same payload data with the service specified as a list (square brackets) and the instance specified in '{' brackets :
curl --location --request POST 'http://172.26.4.193:8080/restconf/data/services'
--data '{ "QoS_SELF-HEALING:QoS_SELF-HEALING": [
{ "name" : "SRVACR", "device" : "RMC01", "interface" : "0/0/0/2"
} ] }'
07-22-2020 02:34 PM
Hi lnunesdo,
You are real close.
I think if you just need remove the service name Qos_SELF_HEALING from the URI (stop at services) in your Post request and use the same payload data with the service specified as a list (square brackets) and the instance specified in '{' brackets :
curl --location --request POST 'http://172.26.4.193:8080/restconf/data/services'
--data '{ "QoS_SELF-HEALING:QoS_SELF-HEALING": [
{ "name" : "SRVACR", "device" : "RMC01", "interface" : "0/0/0/2"
} ] }'
07-22-2020 02:44 PM
Thank you very much @lmanor I tried as you suggested and the call run properly!
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