SwitchPort API returns ''false'' info

RaphaelL
Kind of a big deal
Kind of a big deal

SwitchPort API returns ''false'' info

 Hi ,

 

I have noticed that the call : https://api.meraki.com/api/v1/devices/*******/switch/ports was returning me Trunk ports with voice vlans , which seems fishy at first.

 

For example : 

 

https://api.meraki.com/api/v1/devices/XXXX-XXXX-XXXX/switch/ports

{"portId":"1","name":null,"tags":[],"enabled":true,"poeEnabled":true,"type":"trunk","vlan":1023,"voiceVlan":1031,"allowedVlans":"all","isolationEnabled":false,"rstpEnabled":true,"stpGuard":"disabled","linkNegotiation":"Auto negotiate","portScheduleId":null,"udld":"Alert only","accessPolicyType":"Open"}

 https://api.meraki.com/api/v1/devices/XXXX-XXXX-XXXX/switch/ports/1

{"portId":"1","name":null,"tags":[],"enabled":true,"poeEnabled":true,"type":"trunk","vlan":1023,"voiceVlan":1031,"allowedVlans":"all","isolationEnabled":false,"rstpEnabled":true,"stpGuard":"disabled","linkNegotiation":"Auto negotiate","portScheduleId":null,"udld":"Alert only","accessPolicyType":"Open"}

 

Both endpoints are returning me voicevlan 1031 which is not present in the actual config :

 

RaphaelL_0-1636402632835.png

 

But when looking at the ''access'' tab , I can see the ''other'' config :

 

RaphaelL_1-1636402706539.png

 

 

I'm pretty sure there is a reason for that , something like you can have ''both'' configs ''ready'' in the dashboard so the API returns them. 

 

If the switchport is in trunk mode , just display the trunk values , not the access values. I don't want to go over 3K switchports to remove the values in the access tab for the API to return the correct data.

 

Well... 

 

2 Replies 2
RaphaelL
Kind of a big deal
Kind of a big deal

I wasn't excepting a trunk port and a access port to return the exact same data structure :

 

{"portId":"1","name":null,"enabled":true,"poeEnabled":true,"type":"trunk","vlan":1023,"voiceVlan":1031,"allowedVlans":"all"}
{"portId":"2","name":null,"enabled":true,"poeEnabled":true,"type":"access","vlan":1030,"voiceVlan":1031,"allowedVlans":"all"}

 

( I removed some fields ) 

 

No mention of native vlan ( which is in reality the ''vlan'' ) Allowed vlans list in access mode ( which is not shown in the dashboard ) and so on... 

John_on_API
Meraki Employee
Meraki Employee

Thanks for the feedback. One can see this going either way. Switching data layouts is generally suboptimal when it comes to APIs--better to have a more consistent, predictable set of values returned, rather than having to document conditionally hidden parameters and all the conditions as to why they are hidden (trust me, that's a nightmare).

 

As for voice VLAN -- this value doesn't really make sense for trunk ports. So yes, the value's configured, but you don't really have to worry about it because it has no effect on the configuration. I think it's fair to expect some understanding that voice VLAN applies to access ports and not trunk ports--that's a lot simpler than figuring out conditionally showing/hiding fields.

Get notified when there are additional replies to this discussion.