[SalesForce] PATCH Issue – {“Message”:”The requested resource does not support http method ‘POST’.”}

I have a callout that is having an issue with it's POST. I have seen a couple of work arounds for this issue but none of them seem to work with my integration.

req.setMethod('POST');
req.setHeader('X-HTTP-Method-Override','PATCH');

or

adding "?_HttpMethod=PATCH" to the end of the endpoint

I continue to get the error:

{"Message":"The requested resource does not support http method 'POST'."}

Before I move toward Heroku or MuleSoft, is there any other work arounds that I might not have stumbled across yet?

    HttpRequest request = new HttpRequest();
    //request.setHeader('X-HTTP-Method-Override', 'PATCH');
    request.setMethod('POST');
    request.setHeader('Content-Type', 'application/json');
    request.setHeader('AuthToken', authToken);
    //request.setEndpoint(UPDATE_LEAD_ENDPOINT + '?_HttpMethod=PATCH');
    request.setEndpoint(UPDATE_LEAD_ENDPOINT);
    String requestBody = JSON.serialize(updatedLeadData);
    request.setBody(requestBody);

    Http http = new Http();
    HttpResponse response = http.send(request);
    String responseBody = response.getBody();
    return '';

Best Answer

Aside from other alternatives, a composite request would suffice. This method accepts a POST, and you can specify individual methods (like PATCH) for each of up to 25 requests. You'll just need to adjust the JSON to have this extra metadata.