3

BACKGROUND

I using Apex to get a list of FlowDefinition and would like to update the activeVersionNumber via using a PATCH request.

QUESTION

How can I achieve this using Apex if it does not support the PATCH verb??

0

1 Answer 1

6

Use ?_HttpMethod=PATCH in the request URL.

public static HttpResponse makeHttpCallout(String url, String method, String body, Map<String,String> headers){

    HttpRequest request = new HttpRequest();
    Http http = new Http();

    if(method == 'PATCH'){
        request.setMethod('POST');
        url += '?_HttpMethod=PATCH';
    } else {
        request.setMethod(method);
    }

    request.setEndpoint(url);

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

    if(headers != null){
        for(String key : headers.keySet()){
            request.setHeader(key, headers.get(key));
        }
    }

   return http.send(request);
}

You must log in to answer this question.

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