Get the port details of wireless access point

Paramehswari
Comes here often

Get the port details of wireless access point

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:

Paramehswari_0-1714387929601.png

 

 

Please help me in this

7 Replies 7
alemabrahao
Kind of a big deal
Kind of a big deal

The correct API to GET information about the Switch port is this one:

 

 

"https://api.meraki.com/api/v1/devices/$serial/switchPorts"

 

I am not a Cisco Meraki employee. My suggestions are based on documentation of Meraki best practices and day-to-day experience.

Please, if this post was useful, leave your kudos and mark it as solved.
Malwina
Meraki Employee
Meraki Employee

/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/

Paramehswari
Comes here often

I used but getting bad request below is the screenshot:

Paramehswari_0-1714472027173.png

Could you please help me in this

alemabrahao
Kind of a big deal
Kind of a big deal

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

I am not a Cisco Meraki employee. My suggestions are based on documentation of Meraki best practices and day-to-day experience.

Please, if this post was useful, leave your kudos and mark it as solved.
Paramehswari
Comes here often

Same error:

Paramehswari_0-1714483855028.png

Getting same error.

alemabrahao
Kind of a big deal
Kind of a big deal

Can you send the full error in text please?

This makes it very difficult to analyze.

I am not a Cisco Meraki employee. My suggestions are based on documentation of Meraki best practices and day-to-day experience.

Please, if this post was useful, leave your kudos and mark it as solved.
Paramehswari
Comes here often

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

Paramehswari_0-1714539932907.png

 

 

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.
Labels