There is http package in my flutter project. I want to send a post request with custom header. Here is my code snippet. it will make clear my problem using http for custom header. It always runs else statement means the response type is not 200 and it gives me the error provided Invalid token. but on a post man, it works fine
Map data = {
'user_fullname': _name,
'user_address': _address,
'user_mobile': _phone,
};
var tokenData = {
'User_token': token,
'Content-Type': 'application/x-www-form-urlencoded'
};
final response = await http.post(url, body: data, headers: tokenData);
if (response.statusCode == 200) {
print(response.body);
} else {
print(response.body);
}
User_tokenheader have an upper caseU. (Dart will lower case it as it sends it.) Try your postman request again, but with a lowercaseuser_tokenand see what happens.