M
M
Maxim2016-09-29 10:58:59
Django
Maxim, 2016-09-29 10:58:59

Why doesn't rest_framework want to parse json?

There is a function that accepts json

@csrf_exempt
def update(request):
    if request.method == 'POST':
        try:
            data = JSONParser().parse(request)

The code is running on a server on port 8080 and an address of this kind http://example:8080
is registered. request via pycharm or postman, I get this error
(Pdb) !JSONParser().parse(request)
*** rest_framework.exceptions.ParseError: JSON parse error - Expecting value: line 1 column 1 (char 0)

What could be the problem?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
G
got686, 2016-10-06
@got686

You are most likely sending a POST request. Get hooked with a debugger and see what you have in the input data.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question