title: How to send an array in http POST request body
body: <p>I have an array of objects to add to my cart which I have to send as body parameter in my POST request, something like this:</p>
  <pre><code>[
      {&quot;value&quot;:74,&quot;key&quot;:&quot;product_attribute_53_12_25&quot;},
      {&quot;value&quot;:3,&quot;key&quot;:&quot;product_attribute_1_6_2&quot;},
      {&quot;value&quot;:6,&quot;key&quot;:&quot;product_attribute_1_3_3&quot;},
      {&quot;value&quot;:8,&quot;key&quot;:&quot;product_attribute_1_4_4&quot;},
      {&quot;value&quot;:10,&quot;key&quot;:&quot;product_attribute_1_8_5&quot;},
      {&quot;value&quot;:5,&quot;key&quot;:&quot;addtocart_53.EnteredQuantity&quot;}
  ]
  </code></pre>
  <p>this is my service:</p>
  <pre><code>Future&lt;AddToCartModelResponse&gt; addToCartService() async {
    AddToCartModelResponse model = AddToCartModelResponse();
    Uri uri = Uri.parse(Constants.baseUrl + &quot;AddProductToCart/53/1&quot;);
    Map&lt;String, String&gt; header = {
      &quot;NST&quot;: Constants.NST,
      &quot;Content-Type&quot;: &quot;application/json&quot;,
    };
    var body = {
      //???????????
    };
    try {
      var response = await http.post(uri, body: body, headers: header);
      print(response.body);
      if (response.statusCode == 200) {
        model = AddToCartModelResponse.fromJson(json.decode(response.body));
        return model;
      } else {
        model = AddToCartModelResponse.fromJson(json.decode(response.body));
        model.statusCode = response.statusCode;
        return model;
      }
    } on TimeoutException catch (error, stack) {
      print('error time');
      model.statusCode = 500;
      return model;
    } catch (error, stack) {
      print(error);
      model.statusCode = 500;
      return model;
    }
  }
  </code></pre>
  <p>here, uri set with parameters, and also my body parameters come from productDetail like this:</p>
  <p>[                         {&quot;key&quot;:&quot;product_attribute_{productId}<em>{attributeId}</em>{Id}&quot;, &quot;value&quot;:{attrValueId}},<br />
  {&quot;value&quot;:{quantity}, &quot;key&quot;:&quot;addtocart_{productId}.EnteredQuantity&quot;}
  ]</p>