Python SDK HTTP Proxy Setting

Solved
jpark5591
Conversationalist

Python SDK HTTP Proxy Setting

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?

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

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. 

View solution in original post

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

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. 

Thank you.  That was the solution.

DexterLaBora
Meraki Employee
Meraki Employee

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!

Get notified when there are additional replies to this discussion.
Welcome to the Meraki Community!
To start contributing, simply sign in with your Cisco account. If you don't yet have a Cisco account, you can sign up.