I want to get data received from URL request but I can't access it following is my code
def save_stripe_info(request):
data = request.body
email = data[0]
payment_method_id = data[1]
print('mail=> ',email,' i=> ',payment_method_id, 'hello => ',data)
# some code
it is printing the following output
mail=> 45 i=> 45 hello => b'------WebKitFormBoundary2ndFleWNwV9sa24C\r\nContent-Disposition: form-data; name="email"\r\n\r\ntesti@gmail.com\r\n------WebKitFormBoundary2ndFleWNwV9sa24C\r\nContent-Disposition: form-data; name="payment_method_id"\r\n\r\npm_1K5wvrBbWBJ638dRyJJeYjnL\r\n------WebKitFormBoundary2ndFleWNwV9sa24C--\r\n'
and if I try email = data[email] it gives an error that list indices must be an integer.
how can I get email and payment_method_id from request.
I also tried
body_unicode = request.body.decode('utf-8')
body = json.loads(body_unicode)
content = body['email']
but this is giving error json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)