I've written a Python script to add static routes but I'm running into a JSON error. My original code was messy but worked, appending text to a string until the HTML body was complete
string="{"
string=string + '"name": "' + network["Name"] + '",'
string=string + '"subnet": "' + network["Network"] + '",'
string=string + '"gatewayIp":"' + gateway["GW"] + '",'
string=string + '"enabled":"true"}'
I then tried to use
payload = {
"name" : network["Name"],
"subnet": network["Network"],
"gatewayIp": gateway["GW"],
"enabled":"true"
}
which doesn't work
The output is as follows, the first line is rejected, the second works fine.
{'name': '10.2.1.0-24', 'subnet': '10.2.1.0/24', 'gatewayIp': '192.168.129.5', 'enabled': 'true'}
{"name": "10.2.1.0-24","subnet": "10.2.1.0/24","gatewayIp":"192.168.129.5","enabled":"true"}
The only difference appears to be the quote type. Is the API this picky? and is there a way to use the second code stanza to produce valid code? It works for the requests.request header, but not the body.
Thanks,
Joe