import requests


def post_kalliope_poststuk_uit_confirmation(path, session, data):
    """
    Perform the API-call to send information around the berichtencentrum to Kalliope.

    :param path: url of the api endpoint that we want to send to
    :param session: a Kalliope session, as returned by open_kalliope_api_session()
    :param data: object of parameters for the api call
    :returns: True when we get a 204 response
    """

    headers = {
        "Content-type": "application/json",
        "Accept": "application/json",
    }

    r = session.post(path, json=data, headers=headers)
    if r.status_code == requests.codes.no_content:
        return True
    else:
        try:
            errorDescription = r.json()
        except Exception as e:
            errorDescription = r
        raise requests.exceptions.HTTPError('Failed to post Kalliope poststuck-uit-confirmation (statuscode {}): {}'.format(r.status_code,
                                                                                                             errorDescription))