我正在尝试使用以下方式发送带有一些 JSON 数据的 POST 请求:
curl --verbose -X POST -d @testfile.json http://oururl.com/someapi --header "Content-Type:application/json"
另一端的视图读取request.POST.dict()
-- 但是request.POST
为空(尽管内容长度已设置)!我以前使用过这种方法,从未遇到过这种情况,无法弄清楚出了什么问题。
request.POST
用于表单编码数据。request.body
并将其通过 json.loads()
进行处理。
things=[{"id":5,"column":"foo"}] &lang=en_US &user_country=US
。 - Colleen