I'm working on my first POST method route in my API. For some reason when I pass variables to it via url http://test.com/test?stuff=wee, Flask throws errors like stuff didn't make it through.
Code:
@app.route('/test', methods = ['POST'])
def testindex():
stuff = request.args.get('stuff')
response_message = "success"
response_data = stuff
errors = "None"
response = {
'response message' : response_message,
'response data': response_data,
'errors' : errors
}
js = json.dumps(response)
resp = Response(js, status=200, mimetype='application/json')
return resp
cURL:
curl -H "Content-Type: application/json" -X POST -d '{"stuff":"wee"}' http://test.com/test?stuff=wee
response:
{"errors": "None", "response data": null, "response message": "success"}
Help?