Turns out that Flask sets request.data to an empty string if the content type of the request is application/x-www-form-urlencoded. Since I\'m using
If you want get the JSON when request is 'Content-Type': 'application/x-www-form-urlencoded' you need "force" conversion to json like de code below:
from flask import Flask, request
import os
app = Flask(__name__)
@app.route("/my-endpoint", methods = ['POST'])
def myEndpoint():
requestJson = request.get_json(force=True)
//TODO: do something....
return requestJson
if __name__ == "__main__":
port = int(os.environ.get('PORT', 5000))
app.run(host='0.0.0.0', port=port, debug=True, use_reloader=True)