Learn How We Can Help You Keep Teleworkers Protected During the COVID-19 Crisis

API & Integration

Reply
Highlighted

Need Help:Creating Extensible attribute using API

Authority
Posts: 32
730     0

Hi Team,

 

I want to know is it possible to create new extensible attribute using WAPI?? If yes, please let me know the way. 

 

I didnt find any in the Infoblox API documentation.

Highlighted

Re: Need Help:Creating Extensible attribute using API

Community Manager
Community Manager
Posts: 161
730     0

There are a few examples in the archives, here are a few more.

 

This lists the set of EAs defined on the grid:

 

 

curl -k1 -u admin:infoblox -X GET 'https://192.168.1.2/wapi/v2.8/extensibleattributedef?_return_fields=name,type,list_values'

 

 

This creates a new EA "City".  of type STRING:

 

 

curl -k1 -u admin:infoblox -X POST 'https://10.9.16.6/wapi/v2.8/extensibleattributedef' -H "Content-Type: application/json" -d \
'{
  "name":"City",
  "type":"STRING"
}'

 

 

This creates a new EA "State". of type ENUM (enumerated list), with the value of every U.S. state:

 

 

curl -k1 -u admin:infoblox -X POST 'https://192.168.1.2/wapi/v2.8/extensibleattributedef' -H "Content-Type: application/json" -d \
'{
  "name":"State",
  "type":"ENUM",
  "list_values":[
    {"value":"AL"},
    {"value":"AK"},
    {"value":"AZ"},
    {"value":"AR"},
    {"value":"CA"},
    {"value":"CO"},
    {"value":"CT"},
    {"value":"DE"},
    {"value":"DC"},
    {"value":"FL"},
    {"value":"GA"},
    {"value":"HI"},
    {"value":"ID"},
    {"value":"IL"},
    {"value":"IN"},
    {"value":"IA"},
    {"value":"KS"},
    {"value":"KY"},
    {"value":"LA"},
    {"value":"ME"},
    {"value":"MD"},
    {"value":"MA"},
    {"value":"MI"},
    {"value":"MN"},
    {"value":"MS"},
    {"value":"MO"},
    {"value":"MT"},
    {"value":"NE"},
    {"value":"NV"},
    {"value":"NH"},
    {"value":"NJ"},
    {"value":"NM"},
    {"value":"NY"},
    {"value":"NC"},
    {"value":"ND"},
    {"value":"OH"},
    {"value":"OK"},
    {"value":"OR"},
    {"value":"PA"},
    {"value":"RI"},
    {"value":"SC"},
    {"value":"SD"},
    {"value":"TN"},
    {"value":"TX"},
    {"value":"UT"},
    {"value":"VT"},
    {"value":"VA"},
    {"value":"WA"},
    {"value":"WV"},
    {"value":"WI"},
    {"value":"WY"}
  ]
}'

 

 

 

Highlighted

Re: Need Help:Creating Extensible attribute using API

Authority
Posts: 32
730     0

Thanks Richard.

 

I was successful in creating a new extensible attribute with the below API request

 

curl -k -u admin:infoblox -H 'content-type: application/json' -X POST "https://172.40.165.192/wapi/v2.4/extensibleattributedef?_return_fields%2B=name,type&_return_as_objec..." -d '{"name": "Comments","type": "STRING"}'

 

but the problem is that the above API request creates extensible attribute "comments" for every network view that i have.

 

When I try to put reference for desired network ( in my case testing network view, see bwlow), it throws error

 

"_ref": "network/ZG5zLm5ldHdvcmskMTAuMTAuMC4wLzI0LzI:10.10.0.0/24/Testing",
"network": "10.10.0.0/24",
"network_view": "Testing"

 

API request: 

 

curl -k -u admin:infoblox -H 'content-type: application/json' -X POST "https://172.40.165.192/wapi/v2.4/network/ZG5zLm5ldHdvcmskMTAuMTAuMC4wLzI0LzI:10.10.0.0/24/Testing/ex..." -d '{"name": "Comments","type": "STRING"}'

 

Error:

 

{ "Error": "AdmConProtoError: Unknown argument/field: 'name'",
"code": "Client.Ibap.Proto",
"text": "Unknown argument/field: 'name'"
}

 

I just want to create the extensible attribute for one network view. can you help me in correcting my API request??

Highlighted

Re: Need Help:Creating Extensible attribute using API

Community Manager
Community Manager
Posts: 161
731     0

When you create a new Extensible Attribute it is available for all objects.  (networks, zones, network views, etc.)

 

Did you want to add or change the extensible attribute value for the network view?

 

Also, there are regular attributes, "name" and "comment" for network views, you don't need extensible attributes for those.

 

 

Highlighted

Re: Need Help:Creating Extensible attribute using API

Adviser
Posts: 136
731     0

Hi,

 

My understanding that you are trying to assign a value to the Extensible Attribute for your network.

 

You can do so using the following API

curl -k -u admin:Infoblox -H 'content-type: application/json' -X PUT "https://172.40.165.192/wapi/v2.4/network/ZG5zLm5ldHdvcmskMTAuMTAuMC4wLzI0LzI:10.10.0.0/24/Testing?_return_fields%2B=extattrs&_return_as_object=1" -d '{"extattrs":{"Comments": {"value": "Test"}}}'

Hope this helps,

Krishna

Highlighted

Re: Need Help:Creating Extensible attribute using API

Authority
Posts: 32
731     0

Thanks Richard and Kvasudevan,

 

What I understood is that if i create a new extensible attribute, it will be created for all the network view. I cant create for one single network view.

 

The problem that I am facing is how to use the netwok view when i want to add a record to only one network view.

 

For example: In the below request, I want to add a record with hostname ="ABC" and ip=10.10.0..1 in network view=default.Testing

 

API request:

 

curl -k -u admin:infoblox -H 'content-type: application/json' -X POST "https://172.20.165.192/wapi/v2.4/record:host?_return_fields%2B=name,network_view&_return_as_object=1" -d '{"name":"ABC","ipv4addrs": [{"ipv4addr":"10.10.0.1","configure_for_dhcp":false}],"view":"default.Testing"}'

 

Error: 

but i get the error: "code": "Client.Ibap.Proto",
"text": "Unknown argument/field: 'configue_for_dhcp'"
}

 

Can you help me in fixing this error?

Highlighted

Re: Need Help:Creating Extensible attribute using API

Adviser
Posts: 136
731     0

Hi,

 

From the error message, it looks like you have made a typo: configue_for_dhcp. It should be configure_for_dhcp.

 

Regards,

Krishna Vasudevan

Showing results for 
Search instead for 
Do you mean 

Recommended for You