'receive the data passed in the body of the request API Django Python

I want to get the data passed in the request body like : [1]: https://i.stack.imgur.com/V5s1e.png

My function look like :

def test(request):
        # I want recieve data from body here like
        data = functionRequestBody
        print(data)
        return HttpResponse()


Solution 1:[1]

What information are you looking for? Try request.text, request.session, etc. If your app has users you can get the current user's info through request.user: ex request.user.pk returns the db entry's primary key, request.user.username will return username.

https://www.javatpoint.com/django-request-and-response

Solution 2:[2]

The answer is request.body . I find a better answer on another post StackOverflow

body_unicode = request.body.decode('utf-8')
request = json.loads(body_unicode)

(warning : ended your endpoint with a "/" else is not working) Thx Raphael for your comm !

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 renareps108
Solution 2 Sami R