getOrganizationSwitchPortsBySwitch missing UDLD information

Solved
OliverB
Here to help

getOrganizationSwitchPortsBySwitch missing UDLD information

Hi folks,

 

I'm struggeling a bit with getOrganizationSwitchPortsBySwitch API endpoint.

https://developer.cisco.com/meraki/api-v1/get-organization-switch-ports-by-switch/

 

It does include mostly all configuration parameters of switch ports. But for reasons I do not understand UDLD configuration is not included. To get UDLD config, I must use inefficient getDeviceSwitchPort in addition.

 

Does anybody here know why UDLD config has been excluded?!? Are there any plans to add it?

 

Kind regards,

Oliver Buchholz

1 Accepted Solution
RaphaelL
Kind of a big deal
Kind of a big deal

import os
import json
import requests

api_key = os.environ.get('MERAKI_DASHBOARD_API_KEY')

org_id:str = 'xxxx'
serial:str = 'xxxx'

url:str = "https://api.meraki.com/api/v1/organizations/{org_id}/switch/ports/bySwitch?extendedParams=True"

headers:dict = {
        'X-Cisco-Meraki-API-Key' : api_key,
        'Content-Type': 'application/json'
        }

response = requests.request('GET', url, headers=headers, data="", timeout=60)

print(response.text.encode('utf8'))

 

Simple as that. You might need to enable API beta program through the early access tab from your org.

View solution in original post

8 Replies 8
RaphaelL
Kind of a big deal
Kind of a big deal

Hi , 

 

Have you tested with extendedParams=True ?

OliverB
Here to help

Hi Raphael,

 

I'm not aware of an "extendedParams" parameter and could not find it on the documentation either. Where should I add it, to the getOrganizationSwitchPortsBySwitch request? This does not change anything on the reply.
Here's an example output for one port. It does not contain UDLD:

{
  'portId': '2', 
  'name': 'Test', 
  'tags': ['test'], 
  'enabled': True, 
  'poeEnabled': True, 
  'type': 'access', 
  'vlan': 1, 
  'voiceVlan': 2, 
  'allowedVlans': 'all', 
  'rstpEnabled': True, 
  'stpGuard': 'bpdu guard', 
  'linkNegotiation': 'Auto negotiate', 
  'accessPolicyType': 'Open'
}

 

Kind regards,

Oliver

RaphaelL
Kind of a big deal
Kind of a big deal

{
        "portId": "1",
        "name": null,
        "tags": [],
        "enabled": true,
        "poeEnabled": true,
        "type": "access",
        "vlan": 1022,
        "voiceVlan": 1035,
        "allowedVlans": "all",
        "rstpEnabled": true,
        "stpGuard": "bpdu guard",
        "linkNegotiation": "Auto negotiate",
        "accessPolicyType": "Custom access policy",
        "accessPolicyNumber": 3
      }

 

With : 

 

{"portId": "1", "name": None, "tags": [], "enabled": True, "poeEnabled": True, "type": "access", "vlan": 1022, "voiceVlan": 1035, "allowedVlans": "all", "isolationEnabled": False, "rstpEnabled": True, "stpGuard": "bpdu guard", "linkNegotiation": "Auto negotiate", "portScheduleId": None, "schedule": None, "udld": "Alert only", "linkNegotiationCapabilities": ["Auto negotiate", "1 Gigabit full duplex (forced)", "100 Megabit (auto)", "100 Megabit full duplex (forced)", "10 Megabit (auto)", "10 Megabit full duplex (forced)"], "accessPolicyType": "Custom access policy", "accessPolicyNumber": 3, "daiTrusted": False, "profile": {"enabled": False, "id": "", "iname": None}, "module": {"model": None}, "mirror": {"mode": "Not mirroring traffic"}}
 
 
Sorry for the bad data format. it is case sensitive (Params and not params)
OliverB
Here to help

Hi Raphael,

 

I still did not get where to add the extendedParams. Here's a sample code:

import os
import meraki
import meraki.exceptions

debug: bool = False
api_key = os.environ.get('MERAKI_DASHBOARD_API_KEY')

org_id:str = 'xxxx'
serial:str = 'xxxx'

dashboard: meraki.DashboardAPI = meraki.DashboardAPI(
    api_key=api_key,
    log_path='',
    output_log=debug,
    print_console=debug,
    suppress_logging=not debug)

all_ports_config:list = dashboard.switch.getOrganizationSwitchPortsBySwitch(
    org_id,
    extendedParam=True,
    total_pages=-1,
    serial=serial 
)

print(all_ports_config[0]['ports'][0])

 

Where do I have to add the extendedParams=True?

 

Kind regards,

Oliver

RaphaelL
Kind of a big deal
Kind of a big deal

I don't use the Meraki SDK but I would assume right where you already have it , but without the typo. 

 

extendedParams

OliverB
Here to help

Hi Raphael,

 

sorry to bother you again, but I do not get it working. I've tried it with "extendedParams" with same result.

Now I've created another sample code without Meraki SDK, but same result again.

import os
import json
import requests

api_key = os.environ.get('MERAKI_DASHBOARD_API_KEY')

org_id:str = 'xxxx'
serial:str = 'xxxx'

url:str = "https://api.meraki.com/api/v1/organizations/{org_id}/switch/ports/bySwitch"

headers:dict = {
        'X-Cisco-Meraki-API-Key' : api_key,
        'Content-Type': 'application/json'
        }

payload:str = json.dumps(
    {
        "extendedParams": True,
        "serial": serial
    }
)

response = requests.request('GET', url, headers=headers, data=payload, timeout=60)

print(response.text.encode('utf8'))

Do you have a working example for me?

 

Kind regards,

Oliver

RaphaelL
Kind of a big deal
Kind of a big deal

import os
import json
import requests

api_key = os.environ.get('MERAKI_DASHBOARD_API_KEY')

org_id:str = 'xxxx'
serial:str = 'xxxx'

url:str = "https://api.meraki.com/api/v1/organizations/{org_id}/switch/ports/bySwitch?extendedParams=True"

headers:dict = {
        'X-Cisco-Meraki-API-Key' : api_key,
        'Content-Type': 'application/json'
        }

response = requests.request('GET', url, headers=headers, data="", timeout=60)

print(response.text.encode('utf8'))

 

Simple as that. You might need to enable API beta program through the early access tab from your org.

OliverB
Here to help

Hi Raphael,

 

API beta with early access was making the difference! Thanks for your help!

 

Kind regards,

Oliver

Get notified when there are additional replies to this discussion.