Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

return jsonify(d), 201 breaks the 'application/json' mimetype #478

lbsnrs opened this issue Apr 8, 2012 · 4 comments


None yet
3 participants
Copy link

commented Apr 8, 2012


return jsonify(d), 201

results in returning the client a response with the intended status code and body, but with a text/html mimetype.

I realize this may not be the intended way of using jsonify and the status code shortcut, nevertheless if would be a neat feature.

For the records, if you need to use jsonify and need to return a custom status code you could do

response = jsonify(d)
response.status_code = 201
return response

Or extend jsonify (I created a gist here:


This comment has been minimized.

Copy link

commented Apr 8, 2012

I’m closing this issue since it works properly in 0.9-dev.

@lbsnrs lbsnrs closed this Apr 8, 2012


This comment has been minimized.

Copy link

commented Dec 21, 2015

In Flask==0.10.1 this breaks with:
TypeError: <<class 'pytest_flask.plugin.JSONResponse'> 38 bytes [200 OK]> is not JSON serializable


This comment has been minimized.

Copy link

commented Dec 22, 2015

Flask has the make_response function.

return make_response(jsonify(x=y), 201)

Works very well.


This comment has been minimized.

Copy link

commented Dec 23, 2015

True, thanks. Didn't knew that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.