Skip to content

JSON array payload #50

@asiffer

Description

@asiffer

[Middleware code, middleware.py]
I had an error while posting an array to an endpoint (see the comment). The code expects a dictionary while [I guess] it is ok
to post a raw array (like a batch of records). Maybe the type of json.loads(request.body) can be checked, otherwise the code can be wrapped in a try... except.... Maybe the erros can also occur at the line token = request.GET.get(JWT_QUERYSTRING_ARG)

if request.method == "GET" or request.method == "POST":
    token = request.GET.get(JWT_QUERYSTRING_ARG)
    if not token and request.method == "POST":
        if request.META.get("CONTENT_TYPE") == "application/json":
            # error: AttributeError: 'list' object has no attribute 'get'
            token = json.loads(request.body).get(JWT_QUERYSTRING_ARG)
        if not token:
            token = request.POST.get(JWT_QUERYSTRING_ARG)
else:
    token = None

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions