I am having issues creating a new network when I don't include a "copy_from_network_id". I am using the following code that I got from the Meraki developer site and it works when I specify the "copy_from_network_id" and it doesn't when I don't specify it.
Solved! Go to solution.
The issue with parameter value of None is one of multiple reasons why we are deprecating that Python SDK, which is auto-generated by a third-party tool, with our library/package published in-house.
I can't speak to that code and what it is doing, but I am able to create a new network in an organization using the /organizations/{organizationId}/networks endpoint without specifying a network ID to copy from or a value for disableRemoteStatusPage.
The basics of this code is the following:
import requests
import json
header = {'X-Cisco-Meraki-API-Key': myAPIkey}
header.update({'Content-Type':'application/json'})
orgId = '9876543210'
url = 'https://api.meraki.com/api/v0/organizations/'+orgId+'/networks'
payload = {'name':'Test Network','type':'appliance','timeZone':'US/Eastern'}
response = requests.request('POST', url, data=json.dumps(payload), headers=header)
This code returns a code of 201 and the network does get created.
If I had to guess what the problem is for the supplied code, I would say that create_organization_network.copy_from_network_id needs some kind of value. If you don't want to supply a network ID, try assigning a value of None to it.
Thanks for the reply, I might have to look into the sdk and see what API endpoint it is using. The model defaults the field to None when you don't enter a value which I assume should work but I will try some other options.
Okay so I've done some more testing and there is something the API endpoint doesn't like about passing null (None) through as a value.
I removed the "copyFromNetworkId from the model all together and it worked and this is the data that was sent through to the endpoint.
{"disableMyMerakiCom": false, "disableRemoteStatusPage": false, "name": "Example Network 5", "tags": "", "timeZone": "Australia/Brisbane", "type": "appliance switch wireless"}
I added it back in and this is the data sent to the endpoint which failed.
{"copyFromNetworkId": null, "disableMyMerakiCom": false, "disableRemoteStatusPage": false, "name": "Example Network 7", "tags": "", "timeZone": "Australia/Brisbane", "type": "appliance switch wireless"}
And the reason the value is null is because the model sets all the values to None when it creates the class. So I guess the solution is to just not use the model. Is there anyone who knows anything more about how the models work and what I should be doing to get around this?
Hi Charlotte,
I have just come across this issue.
Please could you provide a more in-depth analysis of how you fixed this issue? I have tried what you posted and am still having the issue!
Thanks!
The issue with parameter value of None is one of multiple reasons why we are deprecating that Python SDK, which is auto-generated by a third-party tool, with our library/package published in-house.
That's odd, our solution is still using an older version of the NodeJS SDK (1.1.0) and has recently started receiving the same error:
{ errorMessage: 'HTTP Response Not OK', errorCode: 400, errorResponse: `{"errors":["'copyFromNetworkId' must be a string"]}` }
It appears to me that the API has recently changed it's behaviour in how it treats the presence (or in our case, absence) of this field. This violates the promise of backwards-compatible changes documented here.
Our previously working automation is broken ahead of our HQ rollout - can you please advise whether the API will be fixed to it's original behaviour?