THE GAME HAS CHANGED

Introducing Infoblox Universal DDI ManagementTM

Watch the launch to discover the new era of management for critical network services. Watch Now

API & Integration, DevOps,NetOps,SecOps

Reply

Can't add a new record:host from python

New Member
Posts: 6
3356     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': 'computer.my.net', 'ipv4addrs': [{'ipv4addr': 'func:nextavailableip:172.16.0.0/20'}]}

 

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

 

If I send more info, like:

{'name': 'computer.my.net', 'ipv4addrs': [{'ipv4addr': 'func:nextavailableip:172.16.0.0/20', '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

Adviser
Posts: 181
3357     0

Hi,

 

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\":\"host.info.com\",\"ipv4addrs\": [{\"ipv4addr\":\"func:nextavailableip:10.10.10.0/24\"}]}"
headers = {'content-type': "application/json"}
response = requests.request("POST", url, auth=('admin', 'Infoblox'), data=payload, headers=headers, verify=False)
print(response.text)

Hope this helps,

Krishna

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

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