I'm creating a simple web api with flask
and sqlalchemy
with marshmallow
as serializer, and here is UserModel
.
class UserModel(db.Model):
__tablename__ = 'users'
id = db.Column(db.Integer, primary_key = True)
username = db.Column(db.String(120), unique = True, nullable = False)
password = db.Column(db.String(120), nullable = False)
user_role = db.Column(db.String(10), nullable = False)
access_token = db.Column(db.String(120), unique = True, nullable = True, default='as' )
refresh_token = db.Column(db.String(120), unique = True, nullable = True, default='as' )
and schema,
class UserSchema(Schema):
username = fields.Str()
password = fields.Str()
user_role = fields.Str()
access_token = fields.Str()
refresh_token = fields.Str()
when i tried to create a user entry using post request with postman like this
{
"username":"test1",
"password":"test1pswd",
"user_role":"admin"
}
it returns the following error on console,
marshmallow.exceptions.ValidationError: {'_schema': ['Invalid input type.']}
What am I doing wrong here?