Home > Mobile >  Flask - sqlalchemy.exc.StatementError: (builtins.TypeError) Not a boolean value: 'False'
Flask - sqlalchemy.exc.StatementError: (builtins.TypeError) Not a boolean value: 'False'

Time:08-18

I want to get the Default value of OnlineAvailability as True. By default, all Doctors will have all Slot Timings Available.

If I give the JSON Body data in Postman and POST the data:

cURL POST in Terminal

cURL POST Error

I added the type argument to the parser.add_argument function call and the same post request through cURL works:

cURL POST Success

Also, looking through the docs for Flask_restplus.reqparse.RequestParser (which is considered deprecated past 2.0, their docs mention it being replaced with a better alternative like marshmallow):

Warning

The whole request parser part of Flask-RESTPlus is slated for removal and will be replaced by documentation on how to integrate with other packages that do the input/output stuff better (such as marshmallow). This means that it will be maintained until 2.0 but consider it deprecated. Don’t worry, if you have code using that now and wish to continue doing so, it’s not going to go away any time too soon.

https://flask-restplus.readthedocs.io/en/stable/parsing.html

CodePudding user response:

Just a small change the code mentioned by nstvnsn, Flask-RESTPlus is no longer being maintained.

So, instead, we can use flask_restx.

from flask_restx import inputs

parser.add_argument("OnlineAvailability", required=False, type=inputs.boolean)
  • Related