0
votes

I have a POST request:

  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;
}

and give an error type '_InternalLinkedHashMap<String, Object>' is not a subtype of type 'String' in type cast What I am doing wrong?

1

1 Answers

0
votes

your body needs to be as string, best case for you could be convert your body as JSON String as below:

  final response = await http.post(url, body: jsonEncode(body), headers: headers);