def jsonex_request(url, data, headers=None):
    """ Make a request with JsonEx
    :param url: URL
    :type url: str
    :param data: Data to POST
    :type data: dict
    :return: Response
    :rtype: dict
    :raises exc.ConnectionError: Connection error
    :raises exc.ServerError: Remote server error (unknown)
    :raises exc.ProviderError: any errors reported by the remote
    """
    # Authentication?
    url, headers = _parse_authentication(url)
    headers['Content-Type'] = 'application/json'

    # Request
    try:
        req = Request(url, headers=headers)
        response = urlopen(req, jsonex_dumps(data))
        res_str = response.read()
        res = jsonex_loads(res_str)
    except HTTPError as e:
        if 'Content-Type' in e.headers and e.headers['Content-Type'] == 'application/json':
            res = jsonex_loads(e.read())
        else:
            raise exc.ServerError('Server at "{}" failed: {}'.format(url, e))
    except URLError as e:
        raise exc.ConnectionError('Connection to "{}" failed: {}'.format(url, e))

    # Errors?
    if 'error' in res:  # Exception object
        raise res['error']  # Error raised by the remote side

    return res
def jsonex_request(url, data, headers=None):
    """ Make a request with JsonEx
    :param url: URL
    :type url: str
    :param data: Data to POST
    :type data: dict
    :return: Response
    :rtype: dict
    :raises exc.ConnectionError: Connection error
    :raises exc.ServerError: Remote server error (unknown)
    :raises exc.ProviderError: any errors reported by the remote
    """
    # Authentication?
    url, headers = _parse_authentication(url)
    headers['Content-Type'] = 'application/json'

    # Request
    try:
        req = Request(url, headers=headers)
        response = urlopen(req, jsonex_dumps(data))
        res_str = response.read()
        res = jsonex_loads(res_str)
    except HTTPError as e:
        if 'Content-Type' in e.headers and e.headers['Content-Type'] == 'application/json':
            res = jsonex_loads(e.read())
        else:
            raise exc.ServerError('Server at "{}" failed: {}'.format(url, e))
    except URLError as e:
        raise exc.ConnectionError('Connection to "{}" failed: {}'.format(url, e))

    # Errors?
    if 'error' in res:  # Exception object
        raise res['error']  # Error raised by the remote side

    return res
def jsonex_request ( url , data , headers = None ) : # Authentication? url , headers = _parse_authentication ( url ) headers [ 'Content-Type' ] = 'application/json' # Request try : req = Request ( url , headers = headers ) response = urlopen ( req , jsonex_dumps ( data ) ) res_str = response . read ( ) res = jsonex_loads ( res_str ) except HTTPError as e : if 'Content-Type' in e . headers and e . headers [ 'Content-Type' ] == 'application/json' : res = jsonex_loads ( e . read ( ) ) else : raise exc . ServerError ( 'Server at "{}" failed: {}' . format ( url , e ) ) except URLError as e : raise exc . ConnectionError ( 'Connection to "{}" failed: {}' . format ( url , e ) ) # Errors? if 'error' in res : # Exception object raise res [ 'error' ] # Error raised by the remote side return res
Make a request with JsonEx
    :param url: URL
    :type url: str
    :param data: Data to POST
    :type data: dict
    :return: Response
    :rtype: dict
    :raises exc.ConnectionError: Connection error
    :raises exc.ServerError: Remote server error (unknown)
    :raises exc.ProviderError: any errors reported by the remote
Make a request with JsonEx : param url : URL : type url : str : param data : Data to POST : type data : dict : return : Response : rtype : dict : raises exc . ConnectionError : Connection error : raises exc . ServerError : Remote server error ( unknown ) : raises exc . ProviderError : any errors reported by the remote