Tutorial - Where to put the "Query param" in Meraki Python Library

NesAlba
Here to help

Tutorial - Where to put the "Query param" in Meraki Python Library

If you are ever wondering where in the hell do I  need to put the Query Parameters inside Meraki python library?

 

Here is your answer

 

In this example, we want to bring a list of the wireless connectivity events for a specific client within a network in the timespan.

 

Meraki API URL:

https://developer.cisco.com/meraki/api-latest/#!get-network-wireless-client-connectivity-events

 

The API documentation looks like this:

What we need:

NesAlba_0-1656604028741.png

 

 

Query: What I can filter by.(we have a lot of options here):

NesAlba_1-1656604028743.png

 

 

i.e If we want to bring only an specific type of severities , you find the “includedSeverities” in que Query list

NesAlba_2-1656604028745.png

 

 

But if you look at a “Meraki Python Library“ template there are no instructions or examples of where in the hell put that Query parameter

NesAlba_3-1656604028750.png

 

 

NesAlba_4-1656604028755.png

 

 

So here is where you need to put the Query parameter:

NesAlba_5-1656604028763.png

 

 

Create a variable “severities” with the includedSeverities valid values and then add “includedSeverities” query parameter in the response… and voilà.

 

So in looks like this:

 

##includedSeverities = query param
##severities = variable with valid value
#in this case the valid values are:  'good', 'info', 'warn' and/or 'bad'.

import meraki
API_KEY = 'xxxxx'
dashboard = meraki.DashboardAPI(API_KEY)

network_id = 'xxxx'
client_id = 'xxxx'
severities= "bad"
response = dashboard.wireless.getNetworkWirelessClientConnectivityEvents(
    network_id, client_id, total_pages= all, includedSeverities =severities
)

print(response)

 

 

Use case example:

If you want a python script to input the severity instead of editing the script.

It should look like this:

 

import meraki
print()
print("Severities")
print("1 -- good")
print("2 -- info")
print("3 -- bad ")
sev = input("Enter the severity exact name:")
API_KEY = '<You API key>'
dashboard = meraki.DashboardAPI(API_KEY)

network_id = '<target Network id>'
client_id = '<target Client id>'
severities= sev
response = dashboard.wireless.getNetworkWirelessClientConnectivityEvents(
    network_id, client_id, total_pages=, includedSeverities =severities)

print(response)

 

.

.

.

And is the same with all Query Parameters 

 

NesAlba_6-1656604391046.png

 

3 Replies 3
RaphaelL
Kind of a big deal
Kind of a big deal

You are correct with that endpoint the documentation or atleast the examples are not taking in account the Parameters. 

 

But the curl query is correct : 

 

curl -L --request GET \
--url https://api.meraki.com/api/v1/networks/{networkId}/wireless/clients/{clientId}/connectivityEvents?includedSeverities=good \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'X-Cisco-Meraki-API-Key: XXXXXXX'

Correct!

 

"Curl"  and "Phyton - request" has the query param

 

Python - request has it in the URL:

      url = "https://api.meraki.com/api/v1/networks/{networkId}/wireless/clients/{clientId}/connectivityEvents?perPage=null&includedSeverities=good&band=2.4&ssidNumber=0&deviceSerial=null"

John-K
Meraki Employee
Meraki Employee

Thanks for writing this up! Good stuff.

Get notified when there are additional replies to this discussion.