import requests
import json


def send_request( url, authKey ):
    """Send a request
    
        Send a request using the provided url and authentication key.
        Raise an exception if the request fails.
        When successful, return the json data replied by the server
    """
    try:
        headers = {'Accept' : 'application/json', 'X-Auth-AccessKey' :authKey }
        r = requests.get(url, headers=headers) 
        r.raise_for_status()
        return json.loads(r.text)
    except Exception as e: 
        raise Exception("send_request failed : \n\t- {} \n\t- {}".format(type(e), e))