Http Post Headers are not working
- Dominant language
- Dart
- Stars
- 1.1k
- Forks
- 419
- Avg merge
- 4d 14h
- Merged PRs (30d)
- 8
Description
I am trying to do a post request in Flutter
Below is the code
final String url = Urls.HOME_URL;
String p = 'Bearer $vAuthToken';
final Map tokenData = {
"Content-Type": "application/x-www-form-urlencoded",
'Vauthtoken': p
};
final Map data = {
'classId': '4',
'studentId': '5'
};
final response = await http.post(Uri.parse(url),
headers: tokenData,
body: jsonEncode(data),
encoding: Encoding.getByName("utf-8"));
if (response.statusCode == 200) {
print(response.body);
} else {
print(response.body);
}
However the header data is not working. I have the correct data and everything. This request works perfectly when done in Postman Client. Any one has any idea what is wrong? Any suggestion is appreciated.
Contributor guide
Assessment
This issue has not been assessed yet.