cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
1223
Views
0
Helpful
5
Replies

Please validate the script

Hi,

I am trying to push this script from postman, getting syntex error, not getting the exact problem.

IN POST SECTION: http://{{apic}}/api/node/mo/uni/tn-{{tenant}}/BD-{{bd-name}}.json  

{
  "fvBD": {
    "attributes": {
      "dn": "uni/tn-{{tenant}}/BD-{{bd-name}}",
      "mac": "00:22:BD:F8:19:FF",
      "name": "{{bd-name}}",
      "rn": "BD-{{bd-name}}",
      "status": "created"
    },
    "children": [
      {
        "fvRsCtx": {
          "attributes": {
            "tnFvCtxName": "Main",
            "status": "created,modified"
          },
          "children": []
        }
      }
    ]
  }

}

Regards

Kumar

1 Accepted Solution

Accepted Solutions

Hi Kumar,

ok, I see. Didn't know about environments and thought you were "hiding" your values...

Anyways:
Tried it with variables now and it didn't work for me either. However, if you change the POST url to https://{{apic}}/api/node/mo.json it does work.

But you need to have the tenant already in place then. If everything should be created if it doesn't exist yet, try this one:

{
    "polUni" : {
        "attributes" : {
        }
        "children : [{
            "fvTenant" : {
                "attributes" : {
                    "name" : "{{tenant}}"
                }
                "children : [{
                    "fvCtx" : {
                        "attributes" : {
                            "name" : "Main"
                        }
                    }
                },
                {
                    "fvBD": {
                        "attributes": {
                          "dn": "uni/tn-{{tenant}}/BD-{{bd-name}}"
                        },
                        "children": [
                          {
                            "fvRsCtx": {
                              "attributes": {
                                "tnFvCtxName": "Main"
                              }
                            }
                          }
                        ]
                    }
                }]
            }
        }]
    }
}

Regards,

Nik

View solution in original post

5 Replies 5

Nik Noltenius
Spotlight
Spotlight

Hi Kumar,

I don't see the problem. Copied your script, exchanged the variables for actual names (shown in blue) and it works fine for me:

{
  "fvBD": {
    "attributes": {
      "dn": "uni/tn-documentation/BD-bd-test",
      "mac": "00:22:BD:F8:19:FF",
      "name": "bd-test",
      "rn": "BD-bd-test",
      "status": "created"
    },
    "children": [
      {
        "fvRsCtx": {
          "attributes": {
            "tnFvCtxName": "Main",
            "status": "created,modified"
          },
          "children": []
        }
      }
    ]
  }

}

I get a 200 OK and the BD actually appears in my tenant.

Could you specify the error you get?

Did you authenticate first?

Did you send the script to the correct URL (https://<APIC_IP>/api/node/mo.json)?

By the way: You don't need most of the stuff, this would work just as fine:

{
  "fvBD": {
    "attributes": {
      "dn": "uni/tn-documentation/BD-bd-test"
    },
    "children": [
      {
        "fvRsCtx": {
          "attributes": {
            "tnFvCtxName": "Main"
          }
        }
      }
    ]
  }
}

Thanks for reviewing script...

its generic script, what I am trying is, have given variables in postman (manage environment --> key and value section). not changing in script, can pass the variables through postman

example:

tenant : documentation

bd-name : bd-test

Regards

Kumar

Hi Kumar,

ok, I see. Didn't know about environments and thought you were "hiding" your values...

Anyways:
Tried it with variables now and it didn't work for me either. However, if you change the POST url to https://{{apic}}/api/node/mo.json it does work.

But you need to have the tenant already in place then. If everything should be created if it doesn't exist yet, try this one:

{
    "polUni" : {
        "attributes" : {
        }
        "children : [{
            "fvTenant" : {
                "attributes" : {
                    "name" : "{{tenant}}"
                }
                "children : [{
                    "fvCtx" : {
                        "attributes" : {
                            "name" : "Main"
                        }
                    }
                },
                {
                    "fvBD": {
                        "attributes": {
                          "dn": "uni/tn-{{tenant}}/BD-{{bd-name}}"
                        },
                        "children": [
                          {
                            "fvRsCtx": {
                              "attributes": {
                                "tnFvCtxName": "Main"
                              }
                            }
                          }
                        ]
                    }
                }]
            }
        }]
    }
}

Regards,

Nik

Issue with URL, fixed, thanks for fix,

seems to be code also has  issue?? not sure what is difference between your code and my code 

No, your code should be fine. I just left out attributes that are not required to get the job done (e.g. "mac": "00:22:BD:F8:19:FF" since it's the default anyway).

Review Cisco Networking for a $25 gift card

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