I used this script also to get the switch port detail
$apiKey = "{APIKEY}"
$url = "https://n121.meraki.com/api/v1/networks/{networkID}/clients/{clientID}"
$headers = @{
"X-Cisco-Meraki-API-Key" = $apikey
}
$response = Invoke-RestMethod -Uri $url -Headers $headers -Method Get
$response
But I didn't get the any port details
OUTPUT:
Please help me in this
The correct API to GET information about the Switch port is this one:
"https://api.meraki.com/api/v1/devices/$serial/switchPorts"
/devices/$serial/switchPorts call is for API v0 version
/devices/{serial}/switch/ports is the current one: https://developer.cisco.com/meraki/api-v1/get-device-switch-ports/
I used but getting bad request below is the screenshot:
Could you please help me in this
This error typically indicates a invalid syntax.
Try this one:
$apiKey = "{APIKEY}"
$serial = "{serial}"
$url = "https://api.meraki.com/api/v1/devices/$serial/switch/ports"
$headers = @{
"X-Cisco-Meraki-API-Key" = $apiKey
}
$response = Invoke-RestMethod -Uri $url -Headers $headers -Method Get
$response
Same error:
Getting same error.
Can you send the full error in text please?
This makes it very difficult to analyze.
I have tried but same error below is the script and output:
script:
$apiKey = "api key"
$serial = "serial number"
$url = "https://api.meraki.com/api/v1/devices/$serial/switch/ports"
$headers = @{
"X-Cisco-Meraki-API-Key" = $apiKey
"Accept" = "application/json"
}
$response = Invoke-RestMethod -Uri $url -Headers $headers -Method Get
$response
Output:
Invoke-RestMethod : The remote server returned an error: (400) Bad Request.
At line:7 char:13
+ $response = Invoke-RestMethod -Uri $url -Headers $headers -Method Get
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-RestMethod], WebException
+ FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeRestMethodCommand