我正试着从这里复制代码
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'