Reply

Removing host record via API without referencing ref value

New Member
Posts: 3
5693     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.

Re: Removing host record via API without referencing ref value

Adviser
Posts: 181
5693     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

Re: Removing host record via API without referencing ref value

New Member
Posts: 3
5693     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"}]'

Re: Removing host record via API without referencing ref value

Moderator
Moderator
Posts: 321
5693     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:##"}

 

Re: Removing host record via API without referencing ref value

New Member
Posts: 3
5693     0

Perfect! thank you

Re: Removing host record via API without referencing ref value

Techie
Posts: 12
5693     0

I'm execute:

curl -k -u admin:infoblox -H 'content-type:application/json' -X POST "https://10.20.20.239/wapi/v2.12.2/request" -d '[{"method": "STATE:ASSIGN","data":{"host_name":"teste.mydomain"}},{"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": "STATESmiley Very HappyISPLAY"}]'

 

 

But I'm getting this error:

 

 

{ "Error": "AdmConProtoError: None ('NoneType' object is not iterable)",
"code": "Server.Ibap.Internal",
"text": "Internal Error"
}curl: (3) unmatched close brace/bracket in URL position 65:
STATE:ASSIGN,data:{host_name:teste.mydomain}},{method:GET,object:
^

 

Could you help in order to understand what is the error ?

Showing results for 
Search instead for 
Did you mean: 

Recommended for You