[SalesForce] HTTP method DELETE doesn’t support output

I've done many integrations so far but none of them required sending an HTTP request with the 'DELETE' method. And today, surprise – HTTP method DELETE doesn't support output appears in my log when I try to make this call.

I couldn't find any related questions/answers on this error apart from this.

The code is simple:

Http h = new Http ();

httpRequest = new HttpRequest ();
httpRequest.setEndpoint('https://somedomain.com/api/deleteRecord/recordId');
httpRequest.setMethod('DELETE');
httpRequest.setBody('');

h.send(httpRequest);

The documentation says that the DELETE method is supported too, though there isn't any additional information on this.

Is there a different way of implementing this method or is there something obvious that I'm missing here?

Best Answer

I'd suggest you need to avoid the call to setBody() when making a DELETE call

I doubt DELETE permits an http body of any size.