I have an API that is sending me a POST request (JSON) for testing. I was doing a lot with the JSON, but all of a sudden it stopped working and giving me a JSONDecodeError. I tried all sorts of things, like using request.POST but nothing worked correctly like I said this was working at one point. Any assistance is appreciated.
Test that gives the error: In the Windows Command prompt, running:
curl -X POST http://127.0.0.1:8000/webhook/webhook_receiver/ -d '{"foo": "bar"}'
Error:
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
View:
def webhook_receiver(request, *args, **kwargs):
    if request.method == 'POST':
        # Get the incoming JSON Data
        data = request.body.decode('utf-8')
        received_json_data = json.loads(data)
        return HttpResponse(received_json_data)
    else:
        return HttpResponse("not Post")
 
     
    