cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
1785
Views
6
Helpful
2
Replies

NSO error "POST on list must be on list element"

lnunesdo
Cisco Employee
Cisco Employee

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

 

1 Accepted Solution

Accepted Solutions

lmanor
Cisco Employee
Cisco Employee

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"
} ] }'

 

View solution in original post

2 Replies 2

lmanor
Cisco Employee
Cisco Employee

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"
} ] }'

 

Thank you very much @lmanor  I tried as you suggested and the call run properly!