Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how do i add a body to my delete http request

Tags:

flutter

dart

I want to add a body to my delete http request but it seems that the http pakage doesnt accept it

http.delete('${config.basicUrl}removeFavorite', body: json.encode(requestBody))

is there any solution for this ?

like image 553
Mohamed hassan kadri Avatar asked Feb 06 '19 15:02

Mohamed hassan kadri


People also ask

Can we add body to delete request?

While it is not explicitly forbidden to include a body with a DELETE request, most HTTP servers do not support it.

How do you pass a body in delete request Axios?

To send a request body with an Axios DELETE request, you should set the data option. Remember that the 2nd parameter to axios. delete() is the Axios options, not the request body. You can't pass the request body as the 2nd parameter like you can with axios.

Can we send payload in delete request angular?

You can send payload along with the DELETE request as part of the params in the options object as follows: this. http. delete('http://testAPI:3000/stuff', { params: { data: yourData }).


1 Answers

  final client = http.Client();
  try {
    final response = await client.send(
        http.Request("DELETE", Uri.parse("${config.basicUrl}removeFavorite"))
          ..headers["authorization"] = "Bearer $bearer"
          ..body = "...");
    //
  } finally {
    client.close();
  }
like image 128
Ski Avatar answered Sep 28 '22 05:09

Ski