Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
ValueError
If the accept parameter is not one of the accepted values.
Returns
-------
resp : byte-like object
The content of the file, which needs to be serialized.
"""
# Get credentials and set request headers
key = config.get('Authentication', 'APIKey')
header = {
'X-ELS-APIKey': key,
'Accept': 'application/json',
'User-Agent': user_agent
}
if config.has_option('Authentication', 'InstToken'):
token = config.get('Authentication', 'InstToken')
header.update({'X-ELS-APIKey': key, 'X-ELS-Insttoken': token})
# Perform request
params.update(**kwds)
# If config.ini has a section as follows:
#
# [Proxy]
# https = protocol://server:port
#
# it uses a proxy as defined
# see requests documentation for details
if config.has_section("Proxy"):
proxyDict = dict(config.items("Proxy"))
resp = requests.get(url, headers=header, proxies=proxyDict, params=params)
else:
resp = requests.get(url, headers=header, params=params)