Q:

Flutter POST with JSON Array

I need to create a post request with a JSON that contains an Array. The http.post method only accepts Map<String, String>. Because of this, I cannot pass a Map with type <String,dynamic> since the Map will contain a List. Here's my code for an explicit HttpClientRequest:
String jsonString = json.encode(body); // encode map to json
List<int> bodyBytes = utf8.encode(jsonString); // utf8 encode
HttpClient client = new HttpClient();
HttpClientRequest request = await client.postUrl(uri);
// it's polite to send the body length to the server

request.headers.set('Content-Length', bodyBytes.length.toString());
request.headers.set('Authorization', '...');
request.headers.set('X-Authorization', apiKey);
request.headers.set("Accept", "application/json");
request.headers.set('Content-Type', 'form-data');
request.add(bodyBytes);
HttpClientResponse response = await request.close();
response.transform(utf8.decoder).listen((contents) {
  // handle data
  return jsonDecode(contents);
});

The problem is, the above request fails. 
EDIT:
The json that is created is: 
{  
   "subject":"PLEASE",
   "message":"JUST. WORK.",
   "filter":"[8]",
}

But the JSON the server expects is:
{  
   "subject":"PLEASE",
   "message":"JUST. WORK.",
   "filter":[8],
}

My main concern is how does one create a JSON array...

A:

Found the problem. There were two main issues:

I was converting the List into a JSON string when adding to the Map. After only adding the List directly to the Map, it seemed to generate the correct JSON.
The content-type must be set to application/json in the request header.

Thanks @Edman for adding some direction.

