Reply

"404 Client Error: Not Found for url" with /range WAPI endpoint (for dhcp failover association)

[ Edited ]
Techie
Posts: 11
5149     0

Hi,

 

I run into a brick with this frustrating issue, can't make it work in our python code.  Yet, it works great in postman.  So weird.  We just recently upgraded to 8.6.3 NIOS.  The python code for no failover association works fine!  Much thanks in advance, for any feedback, as I am trying to meet a hard deadline for my project.

 

requests.exceptions.HTTPError: 404 Client Error: Not Found for url: https://x.x.x.x/wapi/v2.12/range
 
- Python code & postman
grid_master = 'x.x.x.x'
 wapi_version = 'v2.12'
ms_servers = ['dhcp-server-1', 'dhcp-server-2']
 base_url = f"https://{{grid_master}}/wapi/{{wapi_version}}"
 
url = f"{base_url}/range"

if len(ms_servers) > 1:
params = {
"start_addr": start_addr,
"end_addr": end_addr,
"server_association_type": "MS_FAILOVER",
"failover_association": "-".join(ms_servers),
"name": name,
"comment": comment,
}

else:

# No MS failover association.  This works fine!
params = {
"start_addr": start_addr,
"end_addr": end_addr,
"ms_server": {"_struct": "msdhcpserver", "ipv4addr": ms_servers[0]},
"name": name,
"comment": comment,
}

response = self.session.post(url, json=params, verify=False)

 
postman.jpg
 

Re: "404 Client Error: Not Found for url" with /range WAPI endpoint (for dhcp failover ass

[ Edited ]
Techie
Posts: 11
5149     0

I found out what causes the error.  Very weird!  There is nothing wrong with our python code.  Apparently, the 'failover_association' field only accepts a static string. Can Infoblox confirm if this is a bug?  Static string assignment is useless, since our app reads the dhcp servers on the fly, from an external file.

 

So, what works vs what doesn't work:

 

- This one works:

"failover_association": "dhcp-server-1-dhcp-server-2"

 

- These ones don't work, which gives that "404 CLIENT ERROR":

 

"failover_association": "-".join(ms_servers)

"failover_association": servers (where servers is a string variable previously defined, ie, servers = "dhcp-server-1-dhcp-server-2")

 

"failover_association": f"{servers}"

Showing results for 
Search instead for 
Did you mean: 

Recommended for You