07-17-2019 08:31 AM
I'm doing some basic testing with the Python meraki-sdk v1.0.2. The connection to api.meraki.com goes thru an HTTP proxy. Does anyone in the community know how HTTP proxy is configured in the SDK?
Solved! Go to Solution.
07-17-2019 11:50 AM
I don't know about the SDK but I'm using this :
import os
proxy = 'proxyURL'
os.environ['http_proxy'] = proxy
os.environ['HTTP_PROXY'] = proxy
os.environ['https_proxy'] = proxy
os.environ['HTTPS_PROXY'] = proxy
works like a charm.
07-17-2019 11:50 AM
I don't know about the SDK but I'm using this :
import os
proxy = 'proxyURL'
os.environ['http_proxy'] = proxy
os.environ['HTTP_PROXY'] = proxy
os.environ['https_proxy'] = proxy
os.environ['HTTPS_PROXY'] = proxy
works like a charm.
07-18-2019 05:36 AM
Thank you. That was the solution.
07-18-2019 02:44 AM
Hi,
I'm not sure what you mean by a proxy with the SDK, but I will give you some context.
The API default base URL is https://api.meraki.com/api/v0
This path will be redirected to the actual home domain of your Meraki organization.
For example, when I go to https://api.meraki.com/api/v0/organizations, this will actually be redirected to
https://n143.meraki.com/api/v0/organizations
With the SDK, it will naturally use the default base URL, but you have the option to override this. I often do this when I want to manually proxy the request through my own API dev server or if I want to skip the redirect because it could cause issues.
To do this, simply update the configuration for the base URL when you initialize the SDK.
from meraki_sdk.meraki_sdk_client import MerakiSdkClient
from meraki_sdk.exceptions.api_exception import APIException
MerakiSdkClient.config.x_cisco_meraki_api_key = '<API-KEY>'
# Override default Meraki API Base URL
MerakiSdkClient.config.base_uri = "https://n143.meraki.com/api/v0"
client = MerakiSdkClient()
organizations_controller = client.organizations
try:
result = organizations_controller.get_organizations()
print(result)
except APIException as e:
print(e)
Hope this helps!
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