<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def record_goal_attained(experiment_id, user_id, client_id = None):
 """ Record that a variant was successful for a user @param experiment_id : A single experiment id @param user_id : An identifier for the user @param client_id : Bernoulli Client ID """


    if not client_id:
        client_id = os.environ.get('BERNOULLI_CLIENT_ID')

    if not client_id:
        raise Exception("client_id is required")

    try:
        response = requests.post(BASE_URL, data={
            'clientId': client_id,
            'userId': user_id,
            'experimentId': experiment_id,
        })
    except requests.ConnectionError:
        raise Exception("Unable to access services")

    val = response.json()
    if val['status'] != 'ok':
        raise Exception(val['message'])

    return val['value']