Im building a simple api in Django Rest Framework using class based views and the documentation mentions request.data ( https://www.django-rest-framework.org/tutorial/2-requests-and-responses/ )
from rest_framework.views import APIView
class myView(APIView):
def post(self, request):
print(request.data)
When I try to send post requests either with
curl --data param1=val1¶m2=val2 url
The data of all three appears to end up in request.query_params. When I try to print request.data, however I get an empty response {}
I could just use request.query_params, Im just curious as to how one would get data to go to request.data since it is talked about in the documentation
edit: so curl --data param1=val1¶m2=val2 -X POST url
sends information to request.data (now if I say request.query_params if get the empty dict {} but request.data contains an object that is the dict query_params.)
curl request doesn't have the -X and POST added. Add these
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.