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

API & Integration

Accepted Solution

Need som help with python and WAPI

Posts: 4
1604     0



I'm creating some python functions to allocate next available network inside containers and have some problems getting it to work. Hopefully someone here can guide me.


The function i'm currently working with:



def create_network():
    req_url = 'https://grid_ip/wapi/v2.7/networkcontainer/ZG...zA:'
    r = requests.post(url=req_url, auth=('user','pass'), verify=False)
    return r.json()



It seems to work since i get the following response:


<Response [200]>
{'networks': ['', '', '']}



But the container is still empty.


I have also tried the following with the same result:

def create_network():
    req_url = 'https://grid_ip/wapi/v2.7/networkcontainer/ZG...zA:'
    post_data = {'cidr':28, 'num':3}
    r = requests.post(url=req_url, auth=('user','pass'), verify=False, data=json.dumps(post_data))
    return r.json()

If i change the req_url to the following i get it to work:


But that doesent really seem to match Infoblox API-documentation and i want to be able to create several networks in 1 POST and use this function for different network views. I have only been able to get func:nextavailbalenetwork to create in the default networ_view.


I have another Python function that searches the location of  network containers and the result is used for the req_url. But when i use the following req_url with func:nextavailablenetwork the network is still created in network_view default:


and the result:


I started with the Infoblox API today so my knowledge is very limited and i hope someone here can help me understand where i'm failing.



Re: Need som help with python and WAPI

Community Manager
Community Manager
Posts: 356
1605     0

Be sure to check out the Infoblox REST API Guide. You will find handy usage guidelines and examples for exactly what you are trying to do here. Most of the examples are using CURL, but can be adapted for other languages as well.




Existing threads in the Infoblox community will also provide you with helpful examples. This includes:





Showing results for 
Search instead for 
Do you mean 

Recommended for You