Help with Meraki API and Powershell


Help with Meraki API and Powershell

I am having an issue using "Invoke-RestMethod" for Powershell to pull the clients (devices) list. I have setup the API and I am able to get some information like the Admins or the Network ID, Org ID, etc. I just can't seem to figure out how to pull my devices. I have looked at the documentation over and over and it is not working. I end up getting an Error 400: Bad request. 

Here is the documentation I followed to Get Clients:!get-network-clients


Here is my Powershell script (scrubbed). Sorry, they don't have a code button for Powershell:

$orgid = "XXXXX"
$headers = @{
"Content-Type" = "application/json"
"Accept" = "application/json"
"X-Cisco-Meraki-API-Key" = $APIKey

Invoke-RestMethod -Method Get -Uri "$($networkid)/clients" -Headers $Headers


That is what I am thinking (per the documentation) should work. I am not sure where I am going wrong. I have Systems Manager only and I have devices that have been added to it. I would like that list.



I actually got it. I just needed to add "/sm/devices" and that worked

Invoke-RestMethod -Method Get -Uri "$($networkid)/sm/devices"



View solution in original post

Getting noticed

That code runs just fine in a non-SM network so that endpoint is likely not meant for SM, and what you are actually looking for may be one of these!get-network-sm-devices!get-network-sm-users


Exactly! If you want SM devices that's slightly different from network clients.

Get Network Clients

Operation Id:getNetworkClients

Description:List the clients that have used this network in the timespan


Get Network Sm Devices

Operation Id:getNetworkSmDevices

Description:List the devices enrolled in an SM network with various specified fields and filters

I actually got it. I just needed to add "/sm/devices" and that worked

Invoke-RestMethod -Method Get -Uri "$($networkid)/sm/devices"



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.