Activity Forums Salesforce® Discussions What is the difference between PUT and POST methods of REST API in Salesforce?

  • chanchal kumar

    Member
    July 30, 2018 at 11:11 am

    hello Shradha

    HTTP.POST can be used when the client is sending data to the server and the server will decide the URI for the newly created resource, whereas HTTP.PUT can be used when the client is sending data to the server and the client is determining the URI for the newly created resource

  • shariq

    Member
    September 18, 2018 at 11:21 pm

    Hi,

    POST is used to create a new entity. “Post” means “after”; if you have a collection of entities and you tack a new one onto its end, you have posted to the collection. You can’t post an existing entity, and it’s common (though not always required) to use the collection’s URI to post. (E.g. you would create a new Quora user named Noah by POSTing to https://quora.com/users as opposed to https://quora.com/users/noah.)
    PATCH is used to update an existing entity with new information. You can’t patch an entity that doesn’t exist. You would use this when you have a simple update to perform, e.g. changing a user’s name.
    Finally, PUT is used to set an entity’s information completely. PUTting is similar to POSTing, except that it will overwrite the entity if already exists or create it otherwise. You could use a PUT to write a user to your database that may already be in it.

    Hope this helps.

Log In to reply.

Popular Salesforce Blogs

Popular Salesforce Videos