SM Device details API

SOLVED
MohammadFakrulA
Here to help

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
DexterLaBora
Meraki 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
PhilipDAth
Kind of a big deal

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

 

Get notified when there are additional replies to this discussion.
Welcome to the Meraki Community!
To start contributing, simply sign in with your Cisco account. If you don't yet have a Cisco account, you can sign up.