我有一个POST请求:
static String url = 'https://checkout.test.paycom.com/api';
static Map<String, String> headers = {
'Host': 'checkout.test.paycom.com',
'X-Auth': '1234',
'Cache-Control': 'no-cache'
};
Future<Map<String, dynamic>> createCard() async {
try {
Map<String, dynamic> body = {
"id": '123',
"method": "receipts.create",
"params": {
"amount": '2500',
"account": {"order_id": '106'}
}
}
final response = await http.post(url, body: body, headers: headers);
print(response.body);
} catch (e) {
print(e.toString());
}
return null;
}
并给出一个错误
类型'_InternalLinkedHashMap
答案 0 :(得分:0)
您的主体需要为字符串,最好的情况是您可以将主体转换为JSON字符串,如下所示:
final response = await http.post(url, body: jsonEncode(body), headers: headers);