'Create an EnterpriseCourseEnrollment by using the corresponding serializer (for validation).'

def post_enterprise_course_enrollment(self, username, course_id, consent_granted):

    data = {'username': username, 'course_id': course_id, 'consent_granted': consent_granted}
    endpoint = getattr(self.client, 'enterprise-course-enrollment')
    try:
        endpoint.post(data=data)
    except (HttpClientError, HttpServerError):
        message = 'An    error    occured    while    posting    EnterpriseCourseEnrollment    for    user    {username}    and    course    run    {course_id}    (consent_granted    value:    {consent_granted})'.format(username=username, course_id=course_id, consent_granted=consent_granted)
        LOGGER.exception(message)
        raise EnterpriseApiException(message)
