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.
You might want to look at the following thread. You are not the only person having problems doing this.
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?
I use this module and everything has worked ok for me so far.
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.
Thank you all for your help. I will have a look 🙂