-
write test class for htttp request
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;
}
}
Log In to reply.
Popular Salesforce Blogs
Top Reasons to Attend Dreamforce 2024
Table of Contents Top Reasons to Attend Dreamforce 2024 Cutting-Edge Keynotes and Sessions Learn the Hows and Whys of Trusted AI Be on the…
Achieving Optimum Success with Salesforce Managed Services
Salesforce is one of the best sought CRM platforms for businesses, nonprofits, and institutions globally. It comes with the best low-code, visualization, automation, and reporting…
Popular Salesforce Videos
Salesforce Trailhead Bootcamp - Fast Track your Salesforce Certification - $700 OFF LIMITED TIME
If want to fast track the path to your Salesforce Administrator Certification then this video is for you! This offer includes your $200 Certification Voucher…
Things you can do with Loyalty Management in Salesforce to Create Lifelong Customers
Although keeping customers is not always simple, statistics show that when they are a part of an ongoing customer loyalty management program, they spend 67%…
Salesforce - What is customer service?
Believe it or not, your customers’ needs are also your business’s needs. Great customer service ensures customers are so happy, they’ll come back for more…
Popular Salesforce Infographics
ABC's of Salesforce's Apex Coding Language
Apex is a proprietary language developed by Salesforce.com. It is a strongly typed, object-oriented programming language that allows developers to execute flow and transaction control…
The Ultimate Dreamforce Parties 2019
Salesforce Dreamforce has it all. 2700+ sessions, workshops, hands-on demos, product launches, and whatnot. But everyone deserves breaks in between these gripping sessions, right? Dreamforce parties are a…
Significance of Pardot Integration with Salesforce
What is Pardot? Listed as one of the most impeccable tools for B2B marketing, Pardot helps businesses to reach prospects through paid marketing, email campaigns,…