Below is my Http post request its not sending my form-data in body and it is working properly in postman. it requires only email parameter in body which i am passing static for now but still,i think my body is sending empty ,any suggestion please.
Future<Map> getJson() async {
String apiUrl = 'this is my url';
Map<String, String> headers = {
'Content-Type': 'application/json',
'Authorization':'this is my security token'
};
final msg = jsonEncode({
"email":"[email protected]",
});
http.Response response = await http.post(
apiUrl,
headers: headers,
body: msg,
);
return json.decode(response.body); // returns a List type
}
void check() async{
Map _data = await getJson();
print("$_data");
}
@override
void initState() {
super.initState();
check();
}
Postman Response
{
"status": "SUCCESS",
"msg": {
"msg": "Password email reset code has been sent in email. Code will get expire after 24 hours!"
},
"code": 446167
}
My code Response
{status: ERROR, data: {msg: fields are required}}