Are you interested in our Early Access Program (EAP)? This program allows you to preview code, test in your lab and provide feedback prior to General Availability (GA) release of all Infoblox products. If so, please click the link here.

API & Integration, DevOps,NetOps,SecOps


Can't add a new record:host from python

Posts: 5
1917     0

I'm trying to add a new record:host to my InfoBlox from a custom-written python script (yes, I know there's a package, but since I only need some VERY specific things, it's easier to write my own). Depending on what I run, I get one of the following errors:


If I send something like:

{'name': '', 'ipv4addrs': [{'ipv4addr': 'func:nextavailableip:'}]}


I get the error 'List value expected for field: ipv4addrs'


If I send more info, like:

{'name': '', 'ipv4addrs': [{'ipv4addr': 'func:nextavailableip:', 'mac':'11:22:33:44:55:66'}]}


I get 'Arguments can not be repeated (ipv4addrs)'.


Does anyone know what I'm doing wrong? I'm sending a list, as requested, and I'm not repeating anything, but it just doesn't like anything I try to send.



Re: Can't add a new record:host from python

Posts: 179
1917     0



This piece of python code works fine for me.


import requests
requests.packages.urllib3.disable_warnings()  # Disable SSL warnings in requests #
url = "https://grid-master/wapi/v2.11/record:host?_return_as_object=1"
payload = "{\"name\":\"\",\"ipv4addrs\": [{\"ipv4addr\":\"func:nextavailableip:\"}]}"
headers = {'content-type': "application/json"}
response = requests.request("POST", url, auth=('admin', 'Infoblox'), data=payload, headers=headers, verify=False)

Hope this helps,


Re: Can't add a new record:host from python

Posts: 5
1918     0

Nevermind, found my issue. I was passing the data with "data=data" instead of "json=data". When I fix that (and and a "View" field), it works. Would've been nice to get a more useful error message, though.

Showing results for 
Search instead for 
Did you mean: 

Recommended for You