http
http copied to clipboard
dart / flutter not able to make http post request with empty body
I am trying to call post url but the body payload needs to be empty. While requesting the api from postman, it is working fine. However, when calling from dart http.post it is not working.
Here is my code
final response = await http.post(Uri.parse("$baseUrl/api/logout"),
headers: {
"Accept": "*/*",
},
);
which results in 400 response code
and this is my raw http request
POST /api/logout HTTP/1.1
Host: <url>
Accept: */*
which results in 200 response code. API endpoint is POST so, I cannot use GET.