cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
2103
Views
2
Helpful
5
Replies

POST on list must be on list element

victorwsg@gmail.com
Cisco Employee
Cisco Employee

Hi,

I tried to post a request with different types of payload, but no luck.

Anyone can help me on it.


Header 1Header 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.

1 Accepted Solution

Accepted Solutions

frjansso
Cisco Employee
Cisco Employee

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"

  }

}'

View solution in original post

5 Replies 5

frjansso
Cisco Employee
Cisco Employee

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"

  }

}'

I'd also recommend that you start using the RESTCONF API (over the REST API).

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.

I'd say the biggest advantage is that RESTCONF is standardized.

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

Getting Started

Find answers to your questions by entering keywords or phrases in the Search bar above. New here? Use these resources to familiarize yourself with the NSO Developer community: