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

Unable to get CreateInterface API to work | NDFC

Adam Swindell
Level 1
Level 1

Hello. I am trying to use the API "/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/globalInterface" to create a loopback interface.

API reference: API Reference (LAN) - Nexus Dashboard Fabric Controller API, Release 12.2.2 - Cisco DevNet

This is the JSON body I am trying to POST to the API. 

 

{
  "policy": "int_loopback",
  "interfaceType": "INTERFACE_LOOPBACK",
  "interfaces": [
    {
      "serialNumber": "22O2222022",
      "ifName": "Loopback4",
      "nvPairs": {
        "Interface VRF": "site_1_default_vrf",
        "Loopback IP": "10.242.1.2",
        "Route-Map TAG": "12345",
        "Interface Description": "site_1_default_vrf leaf loopback"
     }
   }
  ]
}
 
But then I get this error message
 
[
    {
        "reportItemType": "ERROR",
        "message": "Interface Type is not valid",
        "entity": "BGW-2-SITE-1:Loopback4",
        "line": 0,
        "column": 0
    }
]
 
I've tried all kinds of changes, and modifications to the JSON data but nothing makes any difference. Wondering if anyone can shed some light on this. 
 
Thanks. 
1 Reply 1

The error message "Interface Type is not valid" suggests that the API is complaining about the interfaceType field in your JSON payload, the API swagger doc uses a port channel as an example, but not explicitly list all possible values in this case the loopback. Can you try a GET request and see what the payload looks like for a loopback, i wonder if this is the same like 
'INTERFACE_LOOPBACK_INTERNAL' but that is a guess 
 
I took a shot at this based off this https://developer.cisco.com/docs/nexus-dashboard-fabric-controller/12-2-2/getting-started/#your-first-nexus-dashboard-fabric-controller-api-example guessing here again and wonder if using this and the nvpair gets closer to what you want.
 
{
  "policy": "int_loopback_host",
  "interfaceType": "INTERFACE_LOOPBACK_INTERNAL",
  "interfaces": [
    {
      "serialNumber": "SDKT1234HD",
      "ifName": "Loopback0",
      "nvPairs": {
        "LOOPBACK0_IP_RANGE": "10.1.1.1/32",
        "ADMIN_STATE": "true",
        "DESC": "Loopback interface for testing",
        "MTU": "1500",
        "ENABLE_NETFLOW": "false"
      }
    }
  ]
}
Please mark this as helpful or solution accepted to help others
Connect with me https://bigevilbeard.github.io