Django DRF - Accessing data from POST request forwarded through ngrok
I'm working on a Django REST framework (DRF) API that receives data forwarded from an external endpoint through ngrok. Here's the relevant view code: Python
class MessageReceiver(generics.CreateAPIView):
def post(self, request, org_id, channel_name):
data = request.data
if data:
return Response(
data={
"data": data
},
status=status.HTTP_200_OK
)
return Response(data={'message': 'No data received'}, status=status.HTTP_400_BAD_REQUEST)
My question is: since this is a POST request, I'm unable to access the original forwarded data directly. As I understand, POST requests require a payload to be sent along with the request. How can I effectively access and process the data within request.data in this scenario before I have to hit the endpoint again?