Not getting any data from request object using request.POST.get

Viewed 30

I have a post view that receives an email and payment_method_id. However, when I send this data to this end_point I noticed that I am not retrieving any of the data from my request object. This is an example of what I am sending:

{"email":"test@gmail.com","paymentMethod_id":"pm_1LFMSIDMftTw233Mz3S9xkqE"}

This is my view

@csrf_exempt
@api_view(['POST'])
def save_stripe_info(request):
    email = request.POST.get("email")
    payment_method_id = request.POST.get('payment_method_id')
    print('email is', email)
    print('payment method', payment_method_id)

    customer = stripe.Customer.create(
        email=email,
        payment_method=payment_method_id
    )
    return Response(status=status.HTTP_200_OK, data={
        'message': 'Success',
        'data': {'customer_id': customer.id}
    })
1 Answers
Related