【发布时间】:2021-12-06 04:13:09
【问题描述】:
我想使用 flutter 和 http 将包含另一个 json 数据的 json 数据发布到 API 中
这是我要发送的数据示例
{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
}
]
}
这是我的 API 方法
static Future postSale(body) {
return http.post(Uri.parse('http://192.168.56.1:8000/api/sales/'),
body: body);
}
但是颤振给了我这个错误:
Unhandled Exception: type 'List<Map<String, dynamic>>' is not a subtype of type 'String' in type cast
【问题讨论】: