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

API Examples

Reply
Highlighted

Removing host record via API without referencing ref value

Techie
Posts: 3
594     0

I've got an API from 3rd party VPN appliance that manages the IP pool and it's able to do a record:host in the API but I'm also looking to remove the record on VPN disconnect.

 

Currently use this API to put record in:

 

curl -k -u admin:infoblox -H "content-type: application/json" -X POST "https://10.10.10.10/wapi/v2.10.3/record:host?_return_fields%2B=name,ipv4addrs,&_return_as_object=1" -d "{""name"":""example.company.com"",""ipv4addrs"": [{""ipv4addr"":""10.20.20.20""}]}"

 

One liner curl command would ideally query "example.company.com" and delete.

Highlighted

Re: Removing host record via API without referencing ref value

Adviser
Posts: 136
595     0

Hi,

 

You can use the following multiple object request command to query and delete a host record in a single API call.

 

curl -k -u admin:infoblox -H 'content-type:application/json' -X POST "https://grid-master/wapi/v2.11/request" -d '[{"method": "STATE:ASSIGN","data":{"host_name":"example.infoblox.com"}},{"method":"GET","object": "record:host","data": {"name":"##STATE:host_name:##"},"assign_state": {"host_ref": "_ref"},"enable_substitution": true,"discard": true},{ "method": "DELETE", "object": "##STATE:host_ref:##","enable_substitution": true,"discard": true},{"method": "STATE:DISPLAY"}]'

For more information on mulitple object requests, you can take a look at this blog.

 

Hope this is helpful,

Regards,

Krishna Vasudevan

Highlighted

Re: Removing host record via API without referencing ref value

Techie
Posts: 3
595     0

This is working as expected but ran into one issue, the hostname is case sensitive "example.infoblox.com" is there a way to make the GET case insensitive so "EXAMPLE.infoblox.com" or "example.infoblox.com" works from this online CURL command.

 

curl -k -u admin:infoblox -H 'content-type:application/json' -X POST "https://grid-master/wapi/v2.11/request" -d '[{"method": "STATE:ASSIGN","data":{"host_name":"example.infoblox.com"}},{"method":"GET","object": "record:host","data": {"name":"##STATE:host_name:##"},"assign_state": {"host_ref": "_ref"},"enable_substitution": true,"discard": true},{ "method": "DELETE", "object": "##STATE:host_ref:##","enable_substitution": true,"discard": true},{"method": "STATE:DISPLAY"}]'
Highlighted

Re: Removing host record via API without referencing ref value

Community Manager
Community Manager
Posts: 167
595     0

Use a case-insensitive search.  The search modifier goes immediately after the field being searched, within the quotes.  The difference is subdtle.

 

You want

 

{"name:":"##STATE:host_name:##"}

instead of

 

{"name":"##STATE:host_name:##"}

 

Highlighted

Re: Removing host record via API without referencing ref value

Techie
Posts: 3
595     0

Perfect! thank you

Showing results for 
Search instead for 
Do you mean 

Recommended for You

Businesses are investing heavily into securing company resources from cyber-attacks form cybercrimin