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?

Yehor Androsov
  • 4,885
  • 2
  • 23
  • 40
sm101
  • 562
  • 3
  • 10
  • 28

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

Yehor Androsov
  • 4,885
  • 2
  • 23
  • 40
  • 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. – Yehor Androsov 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