How to post array using http?
var headers = {"Accept": "application/json"};
var url = "https://...."
var response = await http.post(url,
body: {
....
},
I have a param named commentList. I need to pass comment[0], comment[1]... inside body.
Works as you would expect:
List<String> comments = ["1st", "2nd", "3rd"];
Map<String, dynamic> args = {"comments": comments};
String url = "myurl.com";
var body = json.encode(args);
final response = await http
.post(url, body: body, headers: {'Content-type': 'application/json'});
Most helpful comment
Works as you would expect: