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

  • Vikas Kumar

    Member
    January 9, 2017 at 12:39 pm

    Hi sushant,

    HTTP PUT:

    PUT puts a file or resource at a specific URI, and exactly at that URI. If there's already a file or resource at that URI, PUT replaces that file or resource. If there is no file or resource there, PUT creates one. PUT is idempotent, but paradoxically PUT responses are not cacheable.

     

    HTTP POST:

    POST sends data to a specific URI and expects the resource at that URI to handle the request. The web server at this point can determine what to do with the data in the context of the specified resource. The POST method is not idempotent, however POST responses are cacheable so long as the server sets the appropriate Cache-Control and Expires headers.

    The official HTTP RFC specifies POST to be:

    Annotation of existing resources;
    Posting a message to a bulletin board, newsgroup, mailing list, or similar group of articles;
    Providing a block of data, such as the result of submitting a form, to a data-handling process;
    Extending a database through an append operation.

  • Parul

    Member
    September 21, 2018 at 10:46 am

    Adding  some point

    The fundamental difference between the POST and PUT requests is reflected in the different meaning of the Request-URI. The URI in a POST request identifies the resource that will handle the enclosed entity. That resource might be a data-accepting process, a gateway to some other protocol, or a separate entity that accepts annotations. In contrast, the URI in a PUT request identifies the entity enclosed with the request -- the user agent knows what URI is intended and the server MUST NOT attempt to apply the request to some other resource. If the server desires that the request be applied to a different URI, it MUST send a 301 (Moved Permanently) response; the user agent MAY then make its own decision regarding whether or not to redirect the request.

    Thanks

  • Avnish Yadav

    Member
    September 21, 2018 at 12:33 pm

    Hey,

    We use PUT when you can update a resource completely through a specific resource. For instance, if you know that an article resides at http://example.org/article/1234, you can PUT a new resource representation of this article directly through a PUT on this URL.

    If you do not know the actual resource location, for instance, when you add a new article but do not have any idea where to store it, you can POST it to an URL, and let the server decide the actual URL.

    Thanks.

  • shariq

    Member
    September 21, 2018 at 1:34 pm

    Hi,

    GET- In an HTTP GET request, key/value pairs are specified in the URL

    GET requests can be cached
    GET requests remain in the browser history
    GET requests can be bookmarked
    GET requests should never be used when dealing with sensitive data
    GET requests have length restrictions
    GET requests should be used only to retrieve data

    POST –  HTTP POST data is not visible in the URL, and when submitting data to a website.

    POST requests are never cached
    POST requests do not remain in the browser history
    POST requests cannot be bookmarked
    POST requests have no restrictions on data length

    HTTP PUT:

    PUT puts a file or resource at a specific URI, and exactly at that URI. If there’s already a file or resource at that URI, PUT replaces that file or resource. If there is no file or resource there, PUT creates one. PUT is idempotent, but paradoxically PUT responses are not cacheable.

    Thanks

     

Log In to reply.

Popular Salesforce Blogs