我有一个应用程序接口正在向我发送一个JSON请求(JSON,JSON)用于测试。我用JSON做了很多事情,但是突然它停止工作了,给了我一个JSONDecodeError
。我尝试了各种方法,比如使用request.POST
,但都没有像我说的那样正常工作。任何帮助都是非常感谢的。
出现错误的测试:在Windows命令提示符下,运行:
curl -X POST http://127.0.0.1:8000/webhook/webhook_receiver/ -d '{"foo": "bar"}'
错误:
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
查看:
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")
https://stackoverflow.com/questions/50651232
复制相似问题