Take the 2-minute tour ×
Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. It's 100% free, no registration required.

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?

share|improve this question

2 Answers 2

up vote 9 down vote accepted

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.

share|improve this answer

Since I had the code in a static method, I was setting the body to whatever comes in the parameter.

If you ever get this problem, avoid setting the body:

if (String.isNotBlank(body))
{
    httpRequest.setBody(body);
}

Worked like a charm!

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.