06-20-2024 08:15 AM
Hi,
I am using the python merakiDashboardAPI and would like to set the custom user agent string when doing API-callls.
I am following this guide:
https://developer.cisco.com/meraki/api-v1/user-agents-overview/#formatting
This are some parts of my code:
06-20-2024 12:01 PM
If you use urllib.parse package, you can use it to unquote it to something readable.
>>> import meraki
>>> import urllib.parse
>>>
>>> dashboard = meraki.DashboardAPI(
... suppress_logging=True,
... caller="testing testing"
... )
>>>
>>> admins = dashboard.organizations.getOrganizationAdmins(orgID)
>>> apiCalls = dashboard.organizations.getOrganizationApiRequests(orgID)
>>>
>>> print(apiCalls[0]['userAgent'])
python-meraki/1.46.0 %7B%22implementation%22%3A%20%7B%22name%22%3A%20%22CPython%22%2C%20%22version%22%3A%20%223.11.6%22%7D%2C%20%22distro%22%3A%20%7B%22name%22%3A%20%22macOS%22%2C%20%22version%22%3A%20%2214.5%22%7D%2C%20%22system%22%3A%20%7B%22name%22%3A%20%22Darwin%22%2C%20%22release%22%3A%20%2223.5.0%22%7D%2C%20%22cpu%22%3A%20%22arm64%22%2C%20%22caller%22%3A%20%22testing%20testing%22%7D
>>>
>>> testing = urllib.parse.unquote(apiCalls[0]['userAgent'])
>>>
>>> print(testing)
python-meraki/1.46.0 {"implementation": {"name": "CPython", "version": "3.11.6"}, "distro": {"name": "macOS", "version": "14.5"}, "system": {"name": "Darwin", "release": "23.5.0"}, "cpu": "arm64", "caller": "testing testing"}
>>>
06-20-2024 12:39 PM
You can use this:
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide