I am trying to leverage the API to write a script that will periodically check the last connected date for our SM devices.
I happen to be using Powershell, though you tell me if it matters and I still consider myself a bginner when it comes to REST, but I have worked with it.
My first issue is that I'm not sure what format the network id should be in. My network ID is something like 123-456-0789, so I tried that in the URL and I also tried 1234560789, but neither made any difference.
Below is my code, followed by the error I am seeing:
$MerakiApiKey = "32d000fa9c0ce60d4e000cd4d00001b00000053d"
$MerakiUrl = "https://api.meraki.com/api/v0/networks/1234560789/sm/devices?fields=ip,lastConnected&scope=all"
$headers = @{}
$headers.Add("X-Cisco-Meraki-API-KEY",$MerakiApiKey)
$headers.Add("Content-Type","application/json")
Invoke-RestMethod -Method Get -Uri $MerakiUrl -Headers $headers
Error:
Invoke-RestMethod : The remote server returned an error: (404) Not Found.
At line:1 char:1
+ Invoke-RestMethod -Method Get -Uri $MerakiUrl -Headers $headers
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-RestMethod], WebException
+ FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeRestMethodCommand