global with sharing class  MyRestResource13 {
 global static string sendAccount(){

        RestRequest req  = RestContext.request;
        RestResponse res = RestContext.response;
       // map<account,object> account1  = new map<account,object>();

        Blob body = req.requestBody;
        string body1 =body.toString();

        dto df = (dto)json.deserialize(body1 ,dto.class);
        dto dl = new dto(df.name,df.phone,df.website);


        Account a = new account();
        insert a;
        return json.serialize(dl);


public class dto
public string Name{get;set;}
public string phone{get;set;}
public string website{get;set;}
  public dto(String Name,String phone,String Website)

If we Change the Annotations @Httpput and @Httpget also it is Working,then what is the difference between put,get and post,Please anyone Explain with above Code

  • check this doc developer.salesforce.com/docs/atlas.en-us.apexcode.meta/… Apex REST annotations section
    – Ratan Paul
    Apr 20, 2016 at 6:46
  • @sdfcweb the Document specify put method is used for creates and updates the resource,post method is used for creates a new resource,get method is used for request sent and retrieve from Server,Eventhough if you use put annotation instead of post Annotation ,post also updating the resource how and then how it is working Please Explain with Example
    – user30475
    Apr 20, 2016 at 6:51
  • Please anyone Guide Me to Show the Difference
    – user30475
    Apr 20, 2016 at 6:58
  • @itzmukeshy 7,@Olekisy,@Martin,@jenny anyone Guide Me to show the Difference
    – user30475
    Apr 20, 2016 at 7:16
  • It won't make any difference to you, as you are service provider. But it will affect those who use our service. Based on the HTTP method they chose, they will do different operation. Apr 20, 2016 at 8:29

1 Answer 1


The difference between PUT, GET, and POST is almost just convention. If you're writing a service which is querying a database and returning result(s), you'd tend to make it GET. If you're creating an object, you'd tend to use PUT. Since you're writing the service, you can choose the method that makes most sense. For your sendAccount() method, I'd use PUT. That said, I've used REST services which use GET for everything (that has the slight advantage of being what web browsers use, so you can test your service with just a browser).

Technically, there are differences in how the different verbs should behave and the gory details available in these two links:

https://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html http://www.w3schools.com/tags/ref_httpmethods.asp

  • Please make sure with Example,I am not able to get it,how if i use put annotation for creating object
    – user30475
    Apr 20, 2016 at 9:31
  • how we can check with rest services using Web Browser Please Guide Me
    – user30475
    Apr 20, 2016 at 9:48
  • As someone said above, you're writing the service, so you can choose which annotation you think is most appropriate. I'm not sure what else there is to say on that.
    – Aidan
    Apr 20, 2016 at 10:36
  • Then I want to Learn Difference Give some Practical Learning
    – user30475
    Apr 20, 2016 at 10:40

You must log in to answer this question.