如何解决在处理POST REST API调用时缺少2个必需的位置参数:“ user_name”和“ password”
我收到TypeError:sessions_post()缺少2个必需的位置参数:在处理POST REST API调用时,python控制器中的“ user_name”和“ password”,POST调用在http中定义了“ user_name”和“ password”标头,请参见下面的YAML文件:
swagger: '2.0'
info:
version: '0.0.1'
title: sessions
#description: To be provided
# #termsOfService:To be provided
contact:
name: test
paths:
/sessions:
post:
summary: eatablish a session
description: sessions is a collection.This POST creates a new session in the sessions collection and the name of the session returned by this command is the session token.
parameters:
- in: header
name: user_name
type: string
required: true
- in: header
name: password
type: string
required: true
responses:
200:
description: establish a session successfully
400:
$ref: "#/responses/BadRequest"
500:
description: unexpected error
schema:
$ref: '#/definitions/errorModel'
以下是我的python控制器端代码:
def sessions_post(user_name,password):
token = sessions_helper.authenticate(user_name,password)
return 'do some magic!'
以下是卷曲请求:
curl -k -X POST "https://localhost/sessions" -H "accept: application/json" -H "user_name: admin" -H "password: admin" -d ""
我是否错过了HTTP标头“ user_name”和“ password”的任何配置?谢谢。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。