title: Flutter HTTP post request sending list of objects
body: <p>I have successfully got a 200 response code from the server but my API returns response code of 0. When I try to send a request in the postman it response to 1. Maybe I do have something missing in my JSON to send in the body. I'm new to flutter and I would like to send a post HTTP request with a body of list of objects like below: I really appreciate any help.</p>
  <pre><code>
      [
          {
              &quot;product_id&quot;: 14,
              &quot;quantity&quot;: 3,
              &quot;payment&quot;: &quot;COD&quot;
          },
          {
              &quot;product_id&quot;: 3,
              &quot;quantity&quot;: 2,
              &quot;payment&quot;: &quot;COD&quot;
          }
      ]
  
  </code></pre>
  <p>This is my function for HTTP post:</p>
  <pre><code>Future&lt;dynamic&gt; checkItem({Map headers, body, encoding}) async {
      Map&lt;String, String&gt; headers = {
        'Accept': 'application/json',
        'Content-Type': 'application/json',
        'Authorization': 'Bearer $token'
      };
      try {
        final response = await http.post(
            '${_url}transactions/check',
            headers: headers,
            body: body,
            encoding: Encoding.getByName(&quot;utf-8&quot;));
        if (response.statusCode == 200) {
          String data = response.body;
          return jsonDecode(data);
        } else {
          print(response.statusCode);
        }
      } catch (error) {
        print(error);
      }
    }
  
  </code></pre>
  <p>This is how I call the function which I pass my JSON:</p>
  <pre><code> List&lt;String&gt; chckList = checkoutList.map((e) =&gt; json.encode(e.toJson())).toList();
   String strBody = json.encode(chckList);
   final res = await interface.checkOutItem(body: strBody);
  
  </code></pre>
  <p>This is my toJson in my Model object:</p>
  <pre><code>
   Map&lt;String, dynamic&gt; toJson() {
      final Map&lt;String, dynamic&gt; data = new Map&lt;String, dynamic&gt;();
      data['product_id'] = this.product_id;
      data['quantity'] = this.quantity;
      data['payment'] = this.payment;
      return data;
    }
  </code></pre>