Python API - Create Organization Network ->"HTTP response not OK."

Phil17
Comes here often

Python API - Create Organization Network ->"HTTP response not OK."

Hey guys, I'm pretty new to using Python, and I'm having issues creating a new organisation network. I am using the following collect.

 

 

 

 

client = MerakiSdkClient(x_cisco_meraki_api_key)
		networks_controller = client.networks
		collect = {}
		organization_id = '*****'
		collect['organization_id'] = organization_id

		create_organization_network = CreateOrganizationNetworkModel()
		create_organization_network.name = '******'
		create_organization_network.mtype = '******'
		create_organization_network.tags = ' *****'
		create_organization_network.time_zone = '********'
		create_organization_network.disable_my_meraki_com = False
		collect['create_organization_network'] = create_organization_network

		try:
			result = networks_controller.create_organization_network(collect)
			print(result)
		except APIException as error:
			print(error)



>>>HTTP response not OK.

 

 

 

 

As you can see, I pretty much copied the code from the meraki sdk documentation.

 

I hope you guys can help me solving this problem. I would be very happy about any help.

5 Replies 5
CBurkhead
Building a reputation

You might want to look at the following thread. You are not the only person having problems doing this.

 

https://community.meraki.com/t5/Developers-APIs/Bug-with-create-organisation-network-API-Only-works-...

I think it's bugged.

 

The furthest I was able to debug the issue is by looking at the errors spit out by:

print(error.context.response.raw_body)

 

The thing found by @Charlotte in the other topic was indeed one of the things I ran into. The code doesn't like it if you specify no create_organization_network.copy_from_network_id. Setting it to '' (empty string) doesn't work either. So I added an actual network in. But then in the end I got an error 500 which didn't give any hint as to what is happening.

 

The most verbose I could get was by using this piece of code instead of the original:

try:
	result = networks_controller.create_organization_network(collect)
	print(result)
except APIException as error:
	print("Response code: ", error.response_code)
	print("Request: ")
	print(error.context.request.http_method)
	print(error.context.request.query_url)
	print(error.context.request.headers)
	print(error.context.request.query_parameters)
	print(error.context.request.parameters)
	print(error.context.request.files)
	print("Response: ")
	print(error.context.response.status_code)
	print(error.context.response.headers)
	print(error.context.response.raw_body)

 

@DexterLaBora to the rescue?

PhilipDAth
Kind of a big deal
Kind of a big deal

I use this module and everything has worked ok for me so far.

https://github.com/meraki/dashboard-api-python 

CBurkhead
Building a reputation

I wrote my own Python test code, which can be seen in the other thread that I mentioned in a previous post, using requests and the API endpoint. I did not have any issues, either.

Phil17
Comes here often

Thank you all for your help. I will have a look 🙂

Get notified when there are additional replies to this discussion.