- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
Can't add a new record:host from python
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-08-2020 09:48 AM
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.
Solved! Go to Solution.
Re: Can't add a new record:host from python
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-08-2020 09:58 AM
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
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-08-2020 10:14 AM
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.