I am trying to integrate with a third party service, while trying to make a http request , i want to send PATCH as a method,I have looked for two solutions mentioned here in this questionHow can I make a PATCH HTTP Callout from Apex?

In both the solution , i get the exact same error like the one when i tried without the workarounds.The requested resource was not found, or a disallowed method was used.

The service is expecting PATCH as method ,not PUT nor POST and these workarounds are not overriding httpmethod as PATCH.

public class CRMOppUpdate{

public static void performUpdateOnOpportunity(){ 
    String strToken='';
    string scope='crm';
    strToken = BCDBJWToken.getBearerToken(scope);// Fetching Token
    system.debug('strToken '+strToken );
    Doc_Generator_Settings__c docGenSettings = Doc_Generator_Settings__c.getOrgDefaults(); // Custom Settings
    String apiKey =docGenSettings.Client_Id__c;
    STring SiebelEndpoint = docGenSettings.Endpoint_c;
    String requestBody= JSONGeneratorCRM.createJSON();
    HttpRequest req = new HttpRequest();   
    Http http = new Http();
    HTTPResponse responseString;
    string strEndpoint =SiebelEndpoint +'/opportunities/1-2DJLY2S?_HttpMethod=PATCH';

    String authorizationHeader = 'Bearer '+ strToken;
    req.setHeader('Authorization', authorizationHeader);
    PostMethod m = new PostMethod(strEndpoint+ '?_HttpMethod=PATCH');
    //req.setHeader('X-HTTP-Method-Override', 'PATCH');         

    responseString = http.send(req);  



  • 1
    "It doesn't work" is rarely enough to determine a solution. Could you please edit your question to include a verbatim error message and line number, if any, or a detailed description of what negative behavior happens?
    – David Reed
    Dec 3 '18 at 14:37
  • @DavidReed I updated my query , I hope its helpful now
    – Raju Sen
    Dec 3 '18 at 14:44
  • 2
    In the link you mentioned, it says, not all server support the workaround. So if header 'X-HTTP-Method-Override','PATCH' doesnt work then you have to use a middleware Dec 3 '18 at 16:07
  • Thanks you @PranayJaiswal i read it too, but needed to be sure before implementing it
    – Raju Sen
    Dec 4 '18 at 8:36
  • Try below solution,below post is suggesting changing api version. salesforce.stackexchange.com/questions/220244/… Thanks, Rama Dec 4 '18 at 9:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.