0

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 '';
5
  • the endpoint you are referencing doesnt support the POST method, its not really an issue, its just not supported, did you check the api's documentation for supported methods?
    – glls
    Commented Apr 16, 2019 at 18:18
  • Are you trying to use standard REST API endpoints to update a Lead?
    – Jayant Das
    Commented Apr 16, 2019 at 18:26
  • yea the documentation states it can take a POST but it clearly isn't accepting it.
    – Olivia
    Commented Apr 16, 2019 at 18:28
  • @JayantDas yes, I just put them in named credentials but they are standard URL endpoints
    – Olivia
    Commented Apr 16, 2019 at 18:28
  • @Olivia POST is only for creating records, you will need to use PATCH here. I have added references from the docs in my answer.
    – Jayant Das
    Commented Apr 16, 2019 at 18:31

2 Answers 2

1

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.

0

It seems you are trying to utilize the standard REST API endpoint to update a Lead record. If that's the case, then you will need to utilize a PATCH request here. POST is not supported request type for any update requests, it is utilized only for creating records.

This is from Update a Record documentation:

Provide the updated record information in your request data and use the PATCH method of the resource with a specific record ID to update that record.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .