'POST handler.'

def post(self, request, provider_id):

    provider = generics.get_object_or_404(CreditProvider, provider_id=provider_id)
    course_key = request.data.get(u'course_key')
    try:
        course_key = CourseKey.from_string(course_key)
    except InvalidKeyError:
        raise InvalidCourseKey(course_key)
    username = request.data.get(u'username')
    if (not username):
        raise ValidationError({u'detail': u'A    username    must    be    specified.'})
    if (not CreditEligibility.is_user_eligible_for_credit(course_key, username)):
        raise UserNotEligibleException(course_key, username)
    try:
        credit_request = create_credit_request(course_key, provider.provider_id, username)
        return Response(credit_request)
    except CreditApiBadRequest as ex:
        raise InvalidCreditRequest(ex.message)
