cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
5233
Views
2
Helpful
3
Replies

SM Device details API

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"
    ]
}
Is there any specific payload/information need to provide?
Thanks.
1 Accepted Solution

Accepted Solutions

DexterLabora
Cisco Employee
Cisco Employee

When using arrays in a query string, add [] to the param name for each item.

{{baseUrl}}/networks/:networkId/sm/devices?fields[]=foo&fields[]=bar

View solution in original post

3 Replies 3

Philip D'Ath
Meraki Community All-Star
Meraki Community All-Star

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.

DexterLabora
Cisco Employee
Cisco Employee

When using arrays in a query string, add [] to the param name for each item.

{{baseUrl}}/networks/:networkId/sm/devices?fields[]=foo&fields[]=bar

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'))