Bug with create organisation network API? Only works when a copy_from_network_id is specified.

Solved
Charlotte
Here to help

Bug with create organisation network API? Only works when a copy_from_network_id is specified.

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. 

 

collect = {}
organization_id = 'my_org_id'
collect['organization_id'= organization_id

create_organization_network = CreateOrganizationNetworkModel()
create_organization_network.name = 'Long Island Office2'
create_organization_network.mtype = 'appliance switch wireless'
create_organization_network.tags = ' tag1 tag2 '
create_organization_network.time_zone = 'America/Los_Angeles'
#create_organization_network.copy_from_network_id = 'network_id_to_copy'
create_organization_network.disable_my_meraki_com = False
create_organization_network.disable_remote_status_page = False
collect['create_organization_network'= create_organization_network

result = meraki.networks.create_organization_network(collect)
 
I also had issues when I didn't specify the "disable_remote_status_page" field even though it says that is optional and the model defaults it to None.
1 Accepted Solution
chengineer
Meraki Alumni (Retired)
Meraki Alumni (Retired)

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.

Solutions Architect @ Cisco Meraki | API & Developer Ecosystem

View solution in original post

6 Replies 6
CBurkhead
Building a reputation

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.

Charlotte
Here to help

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.

Charlotte
Here to help

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?

Fastburner
Here to help

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!

chengineer
Meraki Alumni (Retired)
Meraki Alumni (Retired)

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.

Solutions Architect @ Cisco Meraki | API & Developer Ecosystem
bly
Here to help

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?

Get notified when there are additional replies to this discussion.