【发布时间】:2019-10-25 08:17:50
【问题描述】:
我正在尝试从这个page复制代码,完整的github代码是here:
该应用程序在浏览器上运行良好,但我无法重现来自 python 的 POST 请求。
我尝试过使用浏览器时显示在有效负载上的相同数据
PEOPLE = {"fname": "DDoug",
"lname": "FarDrell"}
url = "http://localhost:5000/api/people"
data = requests.post(url,data=json.dumps(PEOPLE) )
但我得到以下错误:
data.text
'{\n "detail": "Invalid Content-type (), expected JSON data",\n "status": 415,\n "title": "Unsupported Media Type",\n "type": "about:blank"\n}\n'
我也试过这样:
url = "http://localhost:5000/api/people"
data = requests.post(url,data=json.dumps(PEOPLE) )
但出现此错误:
'{\n "detail": "Invalid Content-type (application/x-www-form-urlencoded), expected JSON data",\n "status": 415,\n "title": "Unsupported Media Type",\n "type": "about:blank"\n}\n'
【问题讨论】: