cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Python SDK HTTP Proxy Setting

SOLVED
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

Accepted Solutions
Highlighted
Getting noticed

Re: Python SDK HTTP Proxy Setting

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. 

3 REPLIES 3
Highlighted
Getting noticed

Re: Python SDK HTTP Proxy Setting

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. 

Meraki Employee

Re: Python SDK HTTP Proxy Setting

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!

Conversationalist

Re: Python SDK HTTP Proxy Setting

Thank you.  That was the solution.

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.