dart-lang / dart-lang/http

Http Post Headers are not working

Open
#382 1 comment 0 reactions 0 assignees View on GitHub
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

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.