i have a problem with Python Flask Restful API and data goes to Elasticsearch, when i post a new data with Postman, problem is:
TypeError: Object of type \'Response\' is
def post(self):
some_json=request.get_json()
return jsonify({'you sent ':some_json})
enough to solve this issue
Inspired from this bug, here is a shorter way of doing it:
from flask import jsonify, make_response
def myMethod():
....
return make_response(jsonify(data), 200)
This can be simply done by:
from flask import jsonify
def myMethod():
....
response = jsonify(data)
response.status_code = 200 # or 400 or whatever
return response
I had a similar problem, the problem is that i was using jsonify twice (jsonify(jsonify({abc:123}))
)