Hi,
The following is the python code I am using to create a new network. Tried so many times with little changes each time to figure out the problem but no luck.Here are the error codes and response I am getting:
error code : 400 bad request
response.text : '{"errors":["Invalid type"]}'
response.raise_for_status : 400 Client Error: Bad Request for url : https://n57.meraki.com/api/v0/organizations/XXX/networks
Help me in understanding the problem ! what exactly is wrong with the code/data format.
Thanks
import requests
import json
def isjson(data):
try:
json_object = json.loads(data)
except ValueError:
return False
return True
url = 'https://api.meraki.com/api/v0/organizations/XXXXX/networks'
#payload = " {\n \"name\": \"office\",\n \"timeZone\": \"CET\",\n \"tags\": \"test\",\n \"type\": \"wireless\"\n }"
headers = {
'X-Cisco-Meraki-API-Key': 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
'Content-Type': 'application/json'
}
payload={
'name':'office',
'timeZone':'CET',
'tags':'test',
'type':'wireless'
}
parsed=json.dumps(payload)
if isjson(parsed):
response = requests.post(url,headers=headers,data=parsed)
print(response.text)