import requests


def post_kalliope_poststuk_in(path, session, params):
    """
    Perform the API-call to send a new poststuk 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 url_params: dict of url parameters for the api call
    :returns: response dict
    """
    r = session.post(path, files=params)
    if r.status_code == requests.codes.ok:
        return r.json()
    else:
        try:
            errorDescription = r.json()
        except Exception as e:
            errorDescription = r
        raise requests.exceptions.HTTPError('Failed to post Kalliope poststuk-in (statuscode {}): {}'.format(r.status_code,
                                                                                                             errorDescription))