I want to check if the request has provided the required headers using Flask-RestPlus.
I tried using the https://flask-restful.readthedocs.io/en/0.3.5/reqparse.html which I used before to check the body for required parameters and it works but I need to also check for headers
def RequestParser():
parser = reqparse.RequestParser()
parser.add_argument('PaymentMethod', location='headers')
return parser
@api.route('/request')
class Request(Resource):
parser = RequestParser()
def post(self):
data = self.parser.parse_args()
paymentMethod = request.headers.get('PaymentMethod')
paymentEndpoint = request.headers.get('PaymentEndpoint')
return paymentMethod
I am expecting that the result will tell me that there is missing headers needed the same result when there are missing parameters in the body.