cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
1025
Views
0
Helpful
1
Replies

Getting API error trying to create DVS with a single API call

Steve Krause
Level 3
Level 3

Hello,

I am attempting to find out how to create a new DVS with a VLAN pool, and VCenter credentials as a single transaction, or at least I would like the entire thing to either complete or fail. Here is what I have come up with

https://APIC-IP/api/node/mo/uni.json

body:

{
  "polUni":{
    "attributes":{

    },
    "children":[
      {
        "infraInfra":{
          "attributes":{
            "dn":"uni/infra",
            "status":"created,modified"
          },
          "children":[
            {
              "fvnsVlanInstP":{
                "attributes":{
                  "allocMode":"dynamic",
                  "descr":"",
                  "dn":"",
                  "name":"DVSWITCH_NAME-Dvs-VlanPool",
                  "ownerKey":"",
                  "ownerTag":"",
                  "status":"created"
                },
                "children":[
                  {
                    "fvnsEncapBlk":{
                      "attributes":{
                        "allocMode":"inherit",
                        "descr":"",
                        "dn":"",
                        "from":"vlan-2000",
                        "name":"",
                        "to":"vlan-2499",
                        "status":"created"
                      }
                    }
                  }
                ]
              }
            },
            {
              "cdpIfPol":{
                "attributes":{
                  "dn":"uni/infra/cdpIfP-DVSWITCH_NAME-Dvs_cdpIfPol",
                  "name":"DVSWITCH_NAME-Dvs_cdpIfPol",
                  "status":"created,modified",
                  "adminSt":"enabled"
                },
                "children":[

                ]
              }
            }
          ]
        }
      },
      {
        "vmmProvP":{
          "attributes":{
            "dn":"uni/vmmp-VMware"
          },
          "children":[
            {
              "vmmDomP":{
                "attributes":{
                  "dn":"uni/vmmp-VMware/dom-DVSWITCH_NAME-Dvs",
                  "name":"DVSWITCH_NAME-Dvs",
                  "rn":"dom-DVSWITCH_NAME-Dvs",
                  "status":"created"
                },
                "children":[
                  {
                    "vmmCtrlrP":{
                      "attributes":{
                        "dn":"uni/vmmp-VMware/dom-DVSWITCH_NAME-Dvs/ctrlr-DVSWITCH_NAME-Dvs-Vcenter",
                        "name":"DVSWITCH_NAME-Dvs-Vcenter",
                        "rootContName":"DATACENTER_NAME",
                        "hostOrIp":"VCENTER_IP_ADDR",
                        "rn":"ctrlr-DVSWITCH_NAME-Dvs-Vcenter",
                        "status":"created"
                      },
                      "children":[
                        {
                          "vmmRsAcc":{
                            "attributes":{
                              "tDn":"uni/vmmp-VMware/dom-DVSWITCH_NAME-Dvs/usracc-DVSWITCH_NAME-Dvs-Cred",
                              "status":"created"
                            },
                            "children":[

                            ]
                          }
                        }
                      ]
                    }
                  },
                  {
                    "infraRsVlanNs":{
                      "attributes":{
                        "tDn":"uni/infra/vlanns-[DVSWITCH_NAME-VlanPool]-dynamic",
                        "status":"created"
                      },
                      "children":[

                      ]
                    }
                  },
                  {
                    "vmmUsrAccP":{
                      "attributes":{
                        "dn":"uni/vmmp-VMware/dom-DVSWITCH_NAME-Dvs/usracc-DVSWITCH_NAME-Dvs-Cred",
                        "name":"DVSWITCH_NAME-Dvs-Cred",
                        "usr":"VCENTER_USERNAME",
                        "pwd":"VCENTER_PASSWORD",
                        "rn":"usracc-DVSWITCH_NAME-Dvs-Cred",
                        "status":"created"
                      },
                      "children":[

                      ]
                    }
                  },
                  {
                    "vmmVSwitchPolicyCont":{
                      "attributes":{
                        "dn":"uni/vmmp-VMware/dom-DVSWITCH_NAME-Dvs/vswitchpolcont",
                        "status":"created,modified"
                      },
                      "children":[
                        {
                          "vmmRsVswitchOverrideCdpIfPol":{
                            "attributes":{
                              "tDn":"uni/infra/cdpIfP-DVSWITCH_NAME-Dvs_cdpIfPol",
                              "status":"created,modified"
                            },
                            "children":[

                            ]
                          }
                        }
                      ]
                    }
                  }
                ]
              }
            }
          ]
        }
      }
    ]
  }
}

The error that I end of getting is

"code": "400",
"text": "Failed to update multiple items in a single operation - request requires distributed transaction. Please modify request to process each item individually"

Any ideas? Thanks!

1 Accepted Solution

Accepted Solutions

Marcel Zehnder
Spotlight
Spotlight

Hi

You cant't post to uni/infra and uni/vmmp-VMware at the same time, because both are toplevel-MOs. You have to do two REST-Posts:

First post the infraInfra-MO to https://{{IP}}/api/mo.json, then post the vmmProvP-MO to https://{{IP}}/api/mo.json.

Also notice, that you only need to provide the DN on your toplevel MOs (infraInfra and vmmProvP)

HTH

Marcel

View solution in original post

1 Reply 1

Marcel Zehnder
Spotlight
Spotlight

Hi

You cant't post to uni/infra and uni/vmmp-VMware at the same time, because both are toplevel-MOs. You have to do two REST-Posts:

First post the infraInfra-MO to https://{{IP}}/api/mo.json, then post the vmmProvP-MO to https://{{IP}}/api/mo.json.

Also notice, that you only need to provide the DN on your toplevel MOs (infraInfra and vmmProvP)

HTH

Marcel

Review Cisco Networking for a $25 gift card

Save 25% on Day-2 Operations Add-On License