You need to sign in to do that
Don't have an account?
sony sonu
THANKS >>>
REST CALLOUTS VISUALFROCE PAGE
public class AnimalsCallouts { public static HttpResponse makeGetCallout() { Http http = new Http(); HttpRequest request = new HttpRequest(); request.setEndpoint('https://th-apex-http-callout.herokuapp.com/animals'); request.setMethod('GET'); HttpResponse response = http.send(request); // If the request is successful, parse the JSON response. if (response.getStatusCode() == 200) { // Deserializes the JSON string into collections of primitive data types. Map<String, Object> results = (Map<String, Object>) JSON.deserializeUntyped(response.getBody()); // Cast the values in the 'animals' key as a list List<Object> animals = (List<Object>) results.get('animals'); System.debug('Received the following animals:'); for (Object animal: animals) { System.debug(animal); } } return response; } public static HttpResponse makePostCallout() { Http http = new Http(); HttpRequest request = new HttpRequest(); request.setEndpoint('https://th-apex-http-callout.herokuapp.com/animals'); request.setMethod('POST'); request.setHeader('Content-Type', 'application/json;charset=UTF-8'); request.setBody('{"name":"mighty moose"}'); HttpResponse response = http.send(request); // Parse the JSON response if (response.getStatusCode() != 201) { System.debug('The status code returned was not expected: ' + response.getStatusCode() + ' ' + response.getStatus()); } else { System.debug(response.getBody()); } return response; } }HOW TO CREATE A VISUALFORCE PAGE FOR THIS APEX CLASS??? WITH TWO BUTTONS OF POST AND GET????
THANKS >>>
Apex class Visual Force Page
Output will look like below
Let us know if this will help you
All Answers
Apex class Visual Force Page
Output will look like below
Let us know if this will help you
I did something similar in my class but am having a hard time writing a test class to cover the code using the mock response generator. How would you create the test class for this? When I call the make callout method it says "Non static method cannot be referenced from a static context". I've tried creating the page reference, calling controller, creating a record, etc. in the test class and none of that seems to resolve the issue.