Reply

Next vaialble ip for a subnet

Techie
Posts: 11
760     0

Hi All

 

I am trying to get the next availble IP for a subnet and reserve it.

 

https://ddi.sss.test.net/wapi/v2.10.5/network/ZG5zLm5ldHdvcmskMTAuMTI0LjExLjAvMjcvMA:10.124.11.0/27/default?_function=next_available_ip&_return_as_object=1 -d {num:1}

But it is giving me error like below

 

    "Error": "AdmConProtoError: Invalid value for _return_as_object: 1 -d {num:1}",
    "code": "Client.Ibap.Proto",
    "text": "Invalid value for _return_as_object: 1 -d {num:1}"

i tried changing things but getting different different errors. taken the _ref for the subnet also.

Please help me in this.

Re: Next vaialble ip for a subnet

Adviser
Posts: 163
761     0

Hi,

 

You would need to do a POST operation to get the next available IP.

curl -k -u admin:infoblox -H 'content-type: application/json' -X POST "https://grid-
master/wapi/v2.11/network/ZG5zLm5ldHdvcmskMTcyLjIxLjEwLjAvMjQvMA:172.21.10.0/24/default?_function
=next_available_ip&_return_as_object=1" -d '{"num":1}' 

You can find the example here.

 

Hope this is helpful,

Thanks & Regards,

Krishna

Re: Next vaialble ip for a subnet

Techie
Posts: 11
761     0

Thanks for your response. but i am usign postman for the request and when i am adding

-d '{"num":1}'

 at the end i am getting below error: 

    "Error": "AdmConProtoError: Invalid value for _return_as_object: 1 -d '{\"num\":1}' ",
    "code": "Client.Ibap.Proto",
    "text": "Invalid value for _return_as_object: 1 -d '{\"num\":1}' "

Re: Next vaialble ip for a subnet

Adviser
Posts: 163
761     0

Hi,

 

In case of Postman, you would have to specify this in the Body section, and not as part of the URL.

Community-WAPI-POSTman.png

Regards,

Krishna Vasudevan

Re: Next vaialble ip for a subnet

[ Edited ]
Community Manager
Community Manager
Posts: 144
761     0

I'd recommend a multiple body request, to retrieve the container ref and generate the new network, all in a single call.

 

Also I'd recommend using Postman variables for the gridmaster IP and WAPI version so they can be adjusted as needed for all calls.

 

The request type is POST and the url is https://{{gridmaster}}/wapi/{{version}}/request

 

The body is:

[
  {
    "method":"GET",
    "object":"networkcontainer",
    "data": {
  		"network": "10.0.0.0/8"
  	},
  	"assign_state": {"my_ref": "_ref" },
    "enable_substitution": true,
    "discard": true
  },
  {
    "method":"POST",
	"object": "network",
	"enable_substitution": true,
	"data": {
      "network": "func:nextavailablenetwork:##STATE:my_ref:##,24",
      "comment": "Created by Next Available Network"
	}
  }
]

 

Here's what it looks like in Postman, with a successful response shown in the response body:

 

next-network.png

Re: Next vaialble ip for a subnet

Techie
Posts: 11
761     0

Thanks for the response @krishna. one more thing i need help is same request further i will use this url in powershell script like below

$url = "https://ddi.sss.st-gin.net/wapi/v2.10.5/network"
$Result = Invoke-RestMethod -Uri $url -Method Get -Credential $creds -Headers $headers -ContentType 'application/json'

So in this case where i have to mention the in the body, so how to do that

num:1

Re: Next vaialble ip for a subnet

Adviser
Posts: 163
761     0

Hi,

 

You would need to specify it as part of the body parameter.

 

$url = "https://grid-master/wapi/v2.11/network/ZG5zLm5ldHdvcmskMTkyLjE2OC4xMS4wLzI0LzA:192.168.11.0/24/default?_function=next_available_ip" 
$pwd = ConvertTo-SecureString "pwd" -AsPlainText -Force 
$creds = New-Object Management.Automation.PSCredential ('admin', $pwd) 
$num_details = @{ 
  num=1} 
$body = $num_details | ConvertTo-Json 
Invoke-RestMethod -Uri $url -Method POST -Credential $creds -ContentType 'application/json' -Body $body 

Regards,

Krishna

Re: Next vaialble ip for a subnet

Techie
Posts: 11
761     0

Thanks a lot @Krishna for your help.

Showing results for 
Search instead for 
Did you mean: 

Recommended for You