Even following many example here & there, i can't get my API work in POST Method. Here the code about it :
from flask import Flask, jsonify, request@app.route('/api/v1/lists', methods=['POST'])
def add_entry():print("p0")content = request.get_json()appname = content.get('title')print(content)print(appname)
When i query with curl (i'm running it on Windows):
curl.exe -i -H "Content-Type: application/json" -X POST -d '{"title":"titi"}' http://localhost:5000/api/v1/lists
curl.exe -i -H "Content-Type: application/json" -X POST -d "{"""title""":"""Read a book"""}" http://localhost:5000/api/v1/lists
I have always a 400 error in return:
HTTP/1.0 400 BAD REQUEST Content-Type: text/html Content-Length: 192 Server: Werkzeug/0.12.1 Python/3.6.0 Date: Tue, 04 Apr 2017 21:55:29 GMT400 Bad Request Bad Request The browser (or proxy) sent a request that this server could not understand.
I dont see where the error is.
Thanks for your help.