+ Start a Discussion
NagShaNagSha 

HTTP RESTresponse In JSON

 

This is my First Rest Class

Need Some Guidance how to connect the HTTP request object with the below class.,

If i am thinking in wrong way,Let me know the right way.,

I need to update the  LocalDB_key value to SRM_ETL_ID__c in  my salesforce instance.

 

JSON STRING:  

{"LocalDB_Key":5109613,"Salesforce_Key":"001Q000000YJZGCIA5","JRM_Object":
"Account","JRM_Field":"SRM_ETL_ID__c"}

 

Apex Class:

 

public class JSON2Apex {
        public String val(Integer LocalDB_Key,String Salesforce_Key,String JRM_Object,String JRM_Field) {
               Http h = new Http();
               List<Account> trips = new List<Account>();
               HttpRequest req = new HttpRequest();
               String url = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx';
               req.setEndpoint(url);
               req.setMethod('POST');
               HttpResponse res = h.send(req);
        }

}

 

 

This is the class Generated from Json2Apex for above JSON

 

public class response {

            public Integer LocalDB_Key;
            public String Salesforce_Key;
            public String JRM_Object;
            public String JRM_Field;


            public static response parse(String json) {
            return (response) System.JSON.deserialize(json, response.class);
            }

}