I want to post json data that contains another json data into API using flutter with http
This is a sample of the data that I want to send
{sales_representative: 1,
doctor: 1,
remark: My Remark,
date: 2021-12-05,
medicines: [
{medicine: 1,
quantity_type: Tablet,
quantity: 55
},
{medicine: 1,
quantity_type: Tablet,
quantity: 5
}
]
}
And this is my API method
static Future postSale(body) {
return http.post(Uri.parse('http://192.168.56.1:8000/api/sales/'),
body: body);
}
But flutter gives my this error:
Unhandled Exception: type 'List<Map<String, dynamic>>' is not a subtype of type 'String' in type cast