Python 解析传入Webhook的JSON

Python 解析传入Webhook的JSON,python,json,django,webhooks,messagebird,Python,Json,Django,Webhooks,Messagebird,我正在尝试构建一个webhook,它接收来自第三方服务Messagebird的JSONPOSTed。在他们的文档中,他们有一个传出查询的示例: GET http://your-own.url/script ?id=e8077d803532c0b5937c639b60216938 &recipient=31642500190 &originator=31612345678 &body=This+is+an+incoming+message

我正在尝试构建一个webhook,它接收来自第三方服务Messagebird的JSON
POST
ed。在他们的文档中,他们有一个传出查询的示例:

GET http://your-own.url/script
    ?id=e8077d803532c0b5937c639b60216938
    &recipient=31642500190
    &originator=31612345678
    &body=This+is+an+incoming+message
    &createdDatetime=2016-05-03T14:26:57+00:00
我的webhook是用Django中的Python构建的,这是我在我的views.py中的内容:

from django.shortcuts import render
from django.views.decorators.http import require_POST
from django.http import HttpResponse
from .models import UserText

@require_POST
def webhookmb(request):
    usrtxt = json.loads(request.body.decode("utf-8"))

    UserText.objects.create(
        id = usrtxt['id']
        recipient = usrtxt['recipient']
        originator = usrtxt['originator']
        body = usrtxt['body']
        createdDatetime = usrtxt['createdDatetime']
    )

    return HttpResponse(200)
我的目标是将JSON读入一个文件
usrtxt
,然后将这些字段映射到一个模型。我收到此错误(部署在heroku上):

JSONDecodeError:应为值:第1行第1列(字符0)


这是因为
json.loads
正在尝试读取文件,而第一个类似项以
GET
开头吗?我需要跳过这一行吗?或者还有其他方法吗?

这可能看起来过于简单,但请尝试将@csrf\u empture decorator添加到您的webhook中。

这可能看起来过于简单,但请尝试将@csrf\u empture decorator添加到您的webhook中。

您找到这个方法了吗?我有一个确切的问题你解决过这个问题吗?我有一个确切的问题