Activity Forums Salesforce® Discussions write test class for htttp request

  • write test class for htttp request

    Posted by Vladimir on December 30, 2020 at 7:55 pm

    Help to write test class for htttp request I can't figure it out
    public with sharing class currencyRates {
    @AuraEnabled
    public static List<Object> getRates(){
    String requestData='https://www.nbrb.by/api/exrates/rates?periodicity=0';
    Http http =new Http();
    HttpRequest request = new HttpRequest();
    request.setEndPoint(requestData);
    request.setMethod('GET');
    HttpResponse response = http.send(request);
    List<Object> result =null;
    if(response.getStatusCode()==200){
    result =(List<Object>)JSON.deserializeUntyped(response.getBody());
    }else{
    ApexPages.Message mes =new ApexPages.Message(ApexPages.Severity.ERROR,'There was an error in reading Data');
    }
    return result;
    }
    }

    Vladimir replied 3 years, 11 months ago 1 Member · 0 Replies
  • 0 Replies

Log In to reply.

Popular Salesforce Blogs

Popular Salesforce Videos

Popular Salesforce Infographics