Activity Forums Salesforce® Discussions what is the difference between post and put in Salesforce?

Tagged: ,

  • Anjali

    Member
    January 16, 2020 at 1:29 pm

    All these annotations are used at the Method level and enables us to expose an Apex method as a REST resource. And here are the differences -

    HttpPut - Used for Create and Update
    HttpPost - Used for Create

    and there is another method also present- HttpPatch - Used for Update
    So if you only wish to create a new record then you can use HttpPost. If you wish to first check if a record exists and only when it does not exists then create a new record, use HttpPut. And if you are sure that the record exists and in case it does not then you wish to throw error then use HttpPatch.

    Hope this helps!

Log In to reply.

Popular Salesforce Blogs

Popular Salesforce Videos