I’m trying to call an API with a custom Body but I always the same error.
Error 400
And the API return “can’t json/yaml decode the argument”
import 'dart:convert';
import 'package:http/http.dart' as http;
import 'dart:developer' as developer;
Future<dynamic> ApiDiolos() async {
final mapHeader = {
'Accept': 'application/json',
'Content-Type': 'application/json',
'X-Diolos-Key':
'My-Custom-API-Key'
};
Uri uri = Uri.parse("https://api.diolos.com/myapipage.php");
var customBody = {};
customBody["action"] = "6";
customBody["limit"] = "null";
customBody["offset"] = "0";
final response = await http.post(uri,
headers: mapHeader,
body: json.encode(customBody.toString()),
encoding: Encoding.getByName('utf-8'));
}
void main() {
ApiDiolos();
}
Return debug for this commands
Every works fine with postman.
I hope you could help myself with this issue.
Thank you
Have a nice day
New contributor
Olivier is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.