Sudden 'meraki.exceptions.SessionInputError:' presented performing basic API calls

Paccers
Building a reputation

Sudden 'meraki.exceptions.SessionInputError:' presented performing basic API calls

Hi all,

 

I've been running basic API calls through Windows WSL environment for a few years now and haven't run in to any problems other than my poor syntax at times. I've created Networks, claimed APs and performed many updates through API calls in that time. Regular Ubuntu apt updates have been performed along with meraki API to stay up to date with no impact on my ability to make calls.

 

As of about two days ago I'm suddenly being thrown the error shown below when performing even the most basic call to getOrganizations (meraki -k <KEY> organizations getOrganizations). I've reinstalled Ubuntu WSL environment & generated a new API key but the issue has persisted, I can't find anything specific to this error online either. I did check out the User Agents guide linked but I got a bit lost!

 

I'm very high-level when it comes to troubleshooting this particular stuff so any pointers in the right direction are greatly appreciated!

 

Current installed Python is v3.12.3

 

Traceback (most recent call last):
File "/home/<MYUSER>/.local/bin/meraki", line 8, in <module>
sys.exit(main())
^^^^^^
File "/home/<MYUSER>/.local/share/pipx/venvs/meraki-cli/lib/python3.12/site-packages/meraki_cli/__main__.py", line 1249, in main
api = meraki.DashboardAPI(args.apiKey, suppress_logging=True,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/<MYUSER>/.local/share/pipx/venvs/meraki-cli/lib/python3.12/site-packages/meraki/__init__.py", line 151, in __init__
self._session = RestSession(
^^^^^^^^^^^^
File "/home/<MYUSER>/.local/share/pipx/venvs/meraki-cli/lib/python3.12/site-packages/meraki/rest_session.py", line 159, in __init__
'User-Agent': f'python-meraki/{self._version} ' + validate_user_agent(self._be_geo_id, self._caller),
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/<MYUSER>/.local/share/pipx/venvs/meraki-cli/lib/python3.12/site-packages/meraki/common.py", line 43, in validate_user_agent
raise SessionInputError("MERAKI_PTYHON_SDK_CALLER", caller, message, doc_link)
meraki.exceptions.SessionInputError: Please follow the user agent format prescribed in our User Agents guide, available here: https://developer.cisco.com/meraki/api-v1/user-agents-overview/

4 Replies 4
JonHumphries
Conversationalist

Hi ,

 

As you have correctly pointed out it appears to be to do with your user-agent.

 

According to Meraki’s guidelines, the User-Agent string should follow this structure:

 

ApplicationName/Version VendorName

 

Rules:

 

  • ApplicationName: Single word, no spaces or special characters

  • Version: Optional but recommended

  • VendorName: Your organization’s name (also without spaces or special characters)

 

Examples:

 

  • PlanetCraftLite/0.8b LunarCommander

  • BurrowFinder/2.5 HappyRabbitProductions

 

 

It looks like the SDK is falling back to the internal default because a custom User-Agent string wasn’t provided, either globally or during initialisation.

 

You can see the fallback behavior here in the SDK:

 

https://github.com/meraki/dashboard-api-python/blob/a026860357c997689c79295c9cac6040cbc13808/meraki/...

 

If you’d like to ask the developers for more detail or suggest improvement, feel free to raise an issue on the SDK repo — they’re usually quite responsive.

 

However in the meantime, if you are not happy to amend your python code directly adding the user-agent, then configure it globally for the SDK here.

 

https://github.com/meraki/dashboard-api-python/blob/main/meraki/config.py

 

 

# Example 1: if your application is named 'Mambo', version number is 5.0, and your vendor/company name is Vega, then
# you would use, at minimum: 'Mambo Vega'. Optionally: 'Mambo/5.0 Vega'.
# Example 2: if your application is named 'Sunshine Rainbows', and company name is 'hunter2 for Life', and if you
# don't want to report version number, then you would use, at minimum: 'SunshineRainbows hunter2ForLife'
# The choice is yours as long as you follow the format. You should **not** include other information in this string.
# If you are an official ecosystem partner, this is required.
# For more guidance, please refer to https://developer.cisco.com/meraki/api-v1/user-agents-overview/
MERAKI_PYTHON_SDK_CALLER = "SunshineRainbows"

 

Hope this helps,

 

Jon

PhilipDAth
Kind of a big deal
Kind of a big deal

Are you using the Meraki SDK?  If so, try updating it.

pip3 install -U meraki

 

If you are not using the Meraki SDK - following that link in the error message to verify that is the format you are using.

https://developer.cisco.com/meraki/api-v1/user-agents-overview/#user-agents

 

Paccers
Building a reputation

Could be coincidence but I updated meraki cli from 1.5.0 to 1.5.1 today and my calls suddenly started working again 😉

JonHumphries
Conversationalist

Great News 🙂 

Get notified when there are additional replies to this discussion.