V
V
Vampre2018-10-01 13:31:54
Django
Vampre, 2018-10-01 13:31:54

How to extract data from json POST request in Django?

I'm trying to confirm the server for the VK application, VK sends a request { "type": "confirmation", "group_id": 156694511 } view
:

def handshake(request):
    if request.method == 'POST':
        data = dict(request.POST)
        if data['type'] == 'confirmation':
            return HttpResponse('token')
    return HttpResponse('Not POST')

As a result, I get a keyerror, because request.POST turns out {}, tell me how to still extract data from the request

Answer the question

In order to leave comments, you need to log in

1 answer(s)
Y
Yura Khlyan, 2018-10-01
@MAGistr_MTM

How do you send a request? If the request is via Axios then the data will be inrequest.body

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question