http icon indicating copy to clipboard operation
http copied to clipboard

dart / flutter not able to make http post request with empty body

Open anil-shrestha opened this issue 3 years ago • 0 comments

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.

anil-shrestha avatar Feb 25 '22 15:02 anil-shrestha