function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
azar khasimazar khasim 

Need some help in Apex Rest Callouts and Test Class in JSON Format for Integration.

Hello Guys,

Actually i have done some Testing of the API Link in POSTMAN Tool whether is it working fine or not, Thus the API Link is working and it is pulling the leads for Salesforce.

Now i am in major part is writing Apex Rest Callouts and Apex Test class for it.

Here i have 
Start Date  ----------- Epoch Converter
End Date  ------------ Epoch Converter
Current Time--------- Epoch Converter
HASH ------- (SHA 256)  UTF-16
hash = %%=SHA256('Insert Text Here','UTF-16')=%%
and
ID 
by using the above Parameters.
I need to write the Callouts and Test Class for it.
GET -- Method,
PUSH -- Integration.

Can anyone please help me from thiss...,


Here is my  Sample code which i have written till now.
****************************************************************************
public class **************Callouts {
 public void getData(Date start_date,Date end_date,Date current_time){
        ***************__mdt data =[select UserName__c,Password__c,url__c from *************__mdt ];
        Http h = new Http();
        HttpRequest req = new HttpRequest();
        request.setEndpoint(data.url__c);
        request.setMethod('POST');
        
     hash = %%=SHA256('Insert Text Here','UTF-16')=%%
        request.setBody(body);
        HttpResponse res = h.send(req);
        result=res.getBody();
        system.debug('result----'+result);
        system.JSONParser jp=json.createParser(result);
 }
     public void invoke(){
        string endpoint= 'https://leads.housing.com/api/v0/get-builder-leads?start_date=&end_date=&current_time=&hash=&id=';
        system.debug('endpoint===='+endpoint);
        http h =new http();
        httpRequest request=new httpRequest();
        request.setEndpoint(endpoint);
        request.setMethod('GET');
        request.setHeader('Authorization','OAuth'+hash);
        system.debug(request.getHeader('Authorization'));
        httpResponse response=h.send(request);
        system.debug('response===='+response);
        result=response.getBody();
    }
     
}

********************************************************************************

Please Help me out from thisss...,

Thanks and Regards,
Azar Khasim.