flutter - no json is sent in the body of my http post flutter - no json is sent in the body of my http post flask flask

flutter - no json is sent in the body of my http post


Try passing :Future<http.Response> postRequest () async {        var url ='http://10.0.2.2:3000/api/message';       Map<String, String> data = { "message": "opa" };        var body = json.encode(data);        var response = await http.post(url,            headers: { "accept": "application/json", "content-type": "application/json" },            body: body        );        print(response.statusCode);        print(response.body);        return response;      }      postRequest().then((response){     print(response.body);});


not sure if my finding is precious or not for community, but it seems that the URL was the problem. Everything works now, but I added a / in the end of the string in my flask app.

In Postman, I didn't have to do this. So if you have same problem, take care :)

The log from Flask server:

127.0.0.1 - - [30/Aug/2019 17:41:32] "POST /api/message/ HTTP/1.1" 200 -opaMy Flask url is:

@app.route('/api/message/', methods=['POST'])def function():