Introducing SOC Insights for BloxOne Threat Defense: Boost your SOC efficiency with AI-driven insights to eliminate manual work and accelerate investigation and response times. Read the blog announcement here.

API & Integration, DevOps,NetOps,SecOps


Can't add a new record:host from python

New Member
Posts: 6
2832     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: 181
2832     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

New Member
Posts: 6
2832     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