09-01-2024 10:48 PM
Hello,
I tried the following on Cisco DevNet Sandbox to add a network and received the following error:
$ python3 Meraki_Post_Network2.py
Traceback (most recent call last):
File "Meraki_Post_Network2.py", line 11, in <module>
requests.post ("/base_url" + org_id +"/organizations",
File "/home/cisco.local/lib/python3.8/site-packages/requests/api.py", line 115, in post
return request("post", url, data=data, json=json, **kwargs)
File "/home/cisco/.local/lib/python3.8/site-packages/requests/api.py", line 59, in request
return session.request(method=method, url=url, **kwargs)
TypeError: request() got an unexpected keyword argument 'networks
Meraki_Post_Network2.py
import requests
import meraki
import json
base_url = "https://n583.meraki.com/"
org_id = "CiscoDevNet"
api_key = "37d5d077d3f88d947e94ed4fad5a388f4cb689b2"
network_name = "New Network"
requests.post ("/base_url" + org_id +"/organizations",
headers = {
"X-Cisco-Meraki-API-Key": "api_key",
"Content-Type": "application/json"
},
networks = json.dumps ({ "name": network_name,
"type": "wireless switch"
}))
I would appreciate, if someone could please take a look.
Thanks,
Solved! Go to Solution.
09-03-2024 02:05 AM
Awesome!
09-02-2024 02:53 AM
Hey @Netmart the error you're encountering is because the requests.post
function doesn't have a keyword argument named "networks"
. Guessing it would be something like this, please test this.
import requests
import json
base_url = "https://n583.meraki.com/"
org_id = "CiscoDevNet"
api_key = "37d5d077d3f88d947e94ed4fad5a388f4cb689b2"
network_name = "New Network"
url = base_url + "api/v1/organizations/" + org_id + "/networks"
headers = {
"X-Cisco-Meraki-API-Key": api_key,
"Content-Type": "application/json"
}
data = {
"name": network_name,
"type": "wireless switch"
}
response = requests.post(url, headers=headers, json=data)
print(response.text)
09-02-2024 07:54 PM
Thank you Stuart.
After revising the code as suggested by you I made some progress, but still received the following error:
"{"errors":["The following required parameters are missing: 'productTypes'"]}
There may be other ways to solve this missing parameter; I did it the following way:
I appreciate your feedback.
Thanks,
Netmart
09-03-2024 02:05 AM
Awesome!
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide