简体   繁体   中英

curl with POST not working, request.POST is empty

I'm attempting to send a post request with some json data using:

curl --verbose -X POST -d @testfile.json http://oururl.com/someapi --header "Content-Type:application/json"

the view on the other end reads request.POST.dict() -- but request.POST is showing up empty (though content length is getting set)! I've used this method before and never had this happen, can't figure out what is going wrong.

You're posting JSON. request.POST is for form-encoded data.

You should be accessing request.body and passing it through json.loads() .

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM