Activity Forums Salesforce® Discussions What is the use of httpPATCH in Salesforce?

  • Anurag

    Member
    July 30, 2018 at 11:00 am

    Hi Sanjana,

    HttpPatch methods are used to do update operation in Salesforce. You have to write class with @httpPatch method which will be used by end user.

  • Parul

    Member
    September 14, 2018 at 5:01 am

    Hi

    HttpPatch Annotation.

    The @HttpPatch annotation is used at the method level and enables you to expose an Apex method as a REST resource. This method is called when an HTTP PATCH request is sent, and updates the specified resource. To use this annotation, your Apex method must be defined as global static.

     

    THanks

  • shariq

    Member
    September 15, 2018 at 2:04 pm

    Hi,

    HttpPatch methods are used to do update operation in salesforce. You have to write class with @httpPatch method which will be used by end user.

    Please refer this:

    @RestResource(urlMapping='/jaichaturvedirestexample/*')
    global with sharing class RESTClass{

    @HttpPatch //use patch for updating record in database. we have to pass record id to fecth it from database and then update it.
    global static String updateAccount(string accnumber){
      String accid1 = RestContext.request.params.get('id');
      Account acc = [select accountnumber from account where id =: accid1];
      acc.accountnumber = accnumber;
      update acc;
      return 'account updated';
    }

    }

    Here end user have to pass account number ot update account record.

    Hope this helps.

Log In to reply.

Popular Salesforce Blogs

Popular Salesforce Videos