Learn How We Can Help You Keep Teleworkers Protected During the COVID-19 Crisis

API & Integration

Accepted Solution

How to specify two IPv4addr's in the dhcpmember JSON payload

Posts: 2
158     0

Hi Infoblox community, 


I am looking to utilize an API call to PUT two members within the DHCP member assignment field. Here is my code in python:


import requests
import json
import sys
import getpass
import pprint


infoblox = "https://X.X.X.X/wapi/v2.10.1/network/eF5zLm5ldHdvcmskMMAuMTM0LjE00C4wLbI0LzA:X.X.X.X/X/default"
payload = '{"network":"10.X.X.X/X","members":[{"_struct":"dhcpmember","ipv4addr":""}]}'
headers = {"Content-type": "application/json", "Accept": "application/json"}
id = 'username'
pw = 'password'
valid_cert = False

response = requests.request("PUT", infoblox, data=payload, headers=headers,
auth=(id, pw), verify=valid_cert)

if response.status_code != requests.codes.ok:
exit_msg = 'Error {} OBJ REF OR PARAMS ARE WRONG: {}'
sys.exit(exit_msg.format(response.status_code, response.reason))

results = response.json()

 My question is how do I specify another IPv4address (lets say in the JSON payload field: [{"_struct":"dhcpmember","ipv4addr":""}]} so that I can have both and in the 10.X.X.X/X network's member assignment? 


Re: How to specify two IPv4addr's in the dhcpmember JSON payload

[ Edited ]
Posts: 2
159     0

Hello again Infoblox community, 


I opened a support ticket with Infoblox and worked with an Engineer who was able to provide an answer to my question! Kudo's to that Engineer! 


Here is the syntax for specifying two IP's in the member assignment field using API (I wrote this in Python so if you're using cURL, it may be a bit different): 


'{"network": "10.X.X.X/X", "members":[{"_struct":"dhcpmember","ipv4addr":""},{"_struct":"dhcpmember","ipv4addr":""}]}'


so basically, it's just a matter of adding a comma and then another {"_struct"} statement. 



Showing results for 
Search instead for 
Do you mean 

Recommended for You