#定义解析规则
parse.add_argument('uname',type=str,required=True,help='用户名错误',trim=True, location="args")
加一个location="args"
即可解决:
"message": "Did not attempt to load JSON data because the request Content-Type was not 'application/json'."
用法:add_argument(name, type=None, default=None, required=False, help=None, location=None, choices=None, action='store', store_missing=True, trim=False);
location
: 这是一个可选的参数,用于指定参数的位置。可以是'args'
(URL查询参数),'json'
(JSON数据),'form'
(表单数据),'headers'
(请求头部)等。