1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Anuncie Aqui
    Anuncie aqui você Também: fdantas@4each.com.br

[Python] Using jsonify with FlaskRESTful returns me a TypeError

Discussão em 'Python' iniciado por Stack, Setembro 16, 2024.

  1. Stack

    Stack Membro Participativo

    app = Flask(__name_))
    api = Api(app)

    class MyClass(Resource):
    def post(self):
    # Here i call a function from a separate file, which returns me a big python dict
    result = my_func()

    return jsonify(result), 200


    This returns me the following error:


    TypeError: Object of type Response is not JSON serializable
    ​

    I tried adding:

    test = jsonify(result), 200


    And there is not error, so this means the endpoint return throws me an error? I do not understand, does Flask-RESTful call jsonify by default or something?

    Continue reading...

Compartilhe esta Página