Reply
Highlighted
Accepted Solution

Sending an Object in GET URL & Wild Search Host or Subnet

[ Edited ]
Ipv6Python
Techie
Posts: 2
1992     0

Main objective is to grab existing data(network and comment) from the grid for this I'm using GET: /wapi/v2.7.1/network. 

 

due to huge Data  restriction, I'm trying to grab single host information. 

 

userinput = input("Enter the host you are looking")

 

Using this GET: /wapi/v1.2/network?network=1.1.1.1/24 for searching the grid according to the user input of address.  

 

 

GET: /wapi/v1.2/network?network=userinput  Is this the right way to send the object in URL? I received below error.   

 

{ "Error": "AdmConDataError: Unexpected address syntax",
"code": "Client.Ibap.Data",
"text": "Unexpected address syntax"
}

 

 

I'm also looking for wild search URL format I can use for GET. 

 

 

 

 

 

Re: Sending an Object in GET URL & Wild Search Host or Subnet

Adviser
Posts: 66
1993     0

Hello,

 

I tried this in my environment with powershell.

$network = Read-Host -Prompt "Network"
$url = "https://grid-master/wapi/v2.7/network?network="+$network
$pwd = ConvertTo-SecureString "infoblox" -AsPlainText -Force
$creds = New-Object Management.Automation.PSCredential ('admin', $pwd)
Invoke-RestMethod -Uri $url -Method GET -Credential $creds

Sample output:
Network: 5.5.5.0/24 <---This is a user prompt

_ref                                                        network    network_view
----                                                        -------    ------------
network/ZG5zLm5ldHdvcmskNS41LjUuMC8yNC8w:5.5.5.0/24/default 5.5.5.0/24 default

If you could tell me what language you are using , I could help you better.

Also, could you elaborate on wild search?

If you want to search for network(s) that begins with a certain value (192.168), you can use the following WAPI call

curl -k -u admin:infoblox -X GET "https://grid-master/wapi/v2.7/network?network~=192.168&_return_as_object=1"

Hope this helps,

Krishna

Re: Sending an Object in GET URL & Wild Search Host or Subnet

Adviser
Posts: 66
1993     0

Hi,

 

I figured you are using python.

 

The input() function is used to read integers. However, you need to read a string. Please use the raw_input() function instead.

import requests
network = raw_input("Network:")
requests.packages.urllib3.disable_warnings()  # Disable SSL warnings in requests #
url = "https://grid-master/wapi/v2.7/network?network=" + network
response = requests.request("GET", url, auth=('admin', 'infoblox'), verify=False)
print(response.text)

Sample Output:
Network:5.5.5.0/24 <--User prompt
[
    {
        "_ref": "network/ZG5zLm5ldHdvcmskNS41LjUuMC8yNC8w:5.5.5.0/24/default",
        "network": "5.5.5.0/24",
        "network_view": "default"
    }
]

Hope this works for you.

Re: Sending an Object in GET URL & Wild Search Host or Subnet

Ipv6Python
Techie
Posts: 2
1993     0

Yea, I am using python. Thank you for the quick response. 

 

Will try this and keep you posted. 

Re: Sending an Object in GET URL & Wild Search Host or Subnet

Ipv6Python
Techie
Posts: 2
1993     0

update:

 

Thank You, this worked. 

Showing results for 
Search instead for 
Do you mean 

Recommended for You