I have a problem posting JSON via curl from cmd (Windows7) to Flask RESTful. This is what I post:
curl.exe -i -H "Content-Type: application/json" \
-H "Accept: application/json" -X POST \
-d '{"Hello":"Karl"}' http://example.net:5000/
It results in a bad request, also I don't know how to debug this, normally I would print out information to console, but this doesn't work. How do you debug wsgi apps? Seems like a hopeless task...
This is my simple test app as seen on the net:
from flask import Flask, request
from flask.ext.restful import Resource, Api
app = Flask(__name__)
api = Api(app)
class Test(Resource):
def post(self):
#printing request.data works
json_data = request.get_json(force=True) # this issues Bad request
# request.json also does not work
return {}
api.add_resource(Test, '/')
if __name__ == '__main__':
app.run(debug=True)