03-11-2021 04:30 PM
Hi,
I am calling the following SM API to get the list of SM devices with some filed details for example "isManaged":
{{baseUrl}}/networks/:networkId/sm/devices?fields={{fields}}
But it's returning following error:
{
"errors": [
"'fields' must be an array"
]
}Solved! Go to Solution.
03-15-2021 01:37 AM
When using arrays in a query string, add [] to the param name for each item.
{{baseUrl}}/networks/:networkId/sm/devices?fields[]=foo&fields[]=bar
03-14-2021 11:18 AM
Here is the documentation for it.
https://developer.cisco.com/meraki/api-v1/#!get-network-sm-devices
Click "Template", "Python-Request" to get an example close to what you want.
It looks like the trick is to not specify the "fields" parameter at all if you don't want to list specific fields.
03-15-2021 01:37 AM
When using arrays in a query string, add [] to the param name for each item.
{{baseUrl}}/networks/:networkId/sm/devices?fields[]=foo&fields[]=bar
03-15-2021 02:33 PM
Thanks @DexterLabora for the tips.
import requests
fields_array = "fields[]=isManaged&fields[]=isSupervised"
network_ID = 'N_1234567890'
url = "https://api.meraki.com/api/v1/networks/{0}/sm/devices?{1}".format(network_ID, fields_array)
payload = None
headers = {
"Content-Type": "application/json",
"Accept": "application/json",
"X-Cisco-Meraki-API-Key": "9abcdefghijklmnopqrstuvzxyz"
}
response = requests.request('GET', url, headers=headers, data = payload)
print(response.text.encode('utf8'))
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