0

I am intending to create a DELETE end point for my .net Core WEB API solution. I will be receiving a json collection of items to be deleted. This will be received from a mobile device. In the DELETE end point how can I capture the collection of items passed. In a similar article I read that DELETE does not accept a message body.

I it possible to capture the json list sent from the mobile device, in the DELETE end point?

user7313094
  • 3,873
  • 2
  • 21
  • 32
sm101
  • 502
  • 2
  • 6
  • 20

1 Answers1

0

It is possible to pass data in request body. I am using ASP.NET Core 3.1

[HttpDelete]
public void Delete(WeatherForecast weatherForecast)
{ }

DELETE request enter image description here

user7313094
  • 3,873
  • 2
  • 21
  • 32
  • I believe sending "POST" data via `HttpDelete` has undefined behavior. In the HTTP spec, it says it's not supported. In his question he linked a question about it. Here is a *heated* conversation about it: https://stackoverflow.com/questions/299628/is-an-entity-body-allowed-for-an-http-delete-request Read the comments under the accepted answer. – Andy Nov 18 '20 at 06:35
  • @Andy I think when we talk about this framework it is pretty deterministic. But thats true that it is subject to test when switching/upgrading framework for your application. – user7313094 Nov 18 '20 at 06:44
  • There are a lot of pitfalls -- especially since he's writing a mobile application, Android, for example, will drop the body of a `HttpDelete` causing your method to fail. – Andy Nov 18 '20 at 06:46