GET request with body is not working on flutter web

Viewed 19

I have a GET request where I need to pass some data as a body. I know its not right, but I cannot change it. I tried it on postman and api is working fine. Then I used postman's code generator to get dart http code. But that code is working on the mobile only, not on the flutter web. Here is the code -

var headers = {
  "content-type": "application/json",
};
var request = http.Request("GET", Uri.parse("https://<domain>/path"));
request.body = json.encode({
  source: 10,
});
request.headers.addAll(headers);

http.StreamedResponse response = await request.send();

if (response.statusCode == 200) {
  print(await response.stream.bytesToString());
} else {
  print(response.reasonPhrase);
}
0 Answers
Related