You need to sign in to do that
Don't have an account?
huskerwendy
How to call my api rest class
I'm not really a developer but have used apex in the past to write triggers. Now I'm trying to use the Rest API to make a call to GoToWebinar's API. I've written some code but am not sure how to test to see if my API call is even working. How do a test that from the Developer Console? Also, when I implement the feature, I am hoping to have it execute without human interaction as a job that runs each night. How do you do that?
Here's my code:
Here's my code:
public class g2wCallout { public void getWebinars(){ HttpRequest req = new HttpRequest(); //Set HTTPRequest Method req.setMethod('GET'); //Set HTTPRequest header properties req.setHeader('content-type', 'application/json'); req.setHeader('Accept','application/json'); req.setHeader('Authorization','OAuth '); req.setEndpoint( 'https://api.citrixonline.com/G2W/rest/organizers/3131084/historicalWebinars?fromTime=2015-05-28T18:00:00Z&toTime=2015-05-28T24:00:00Z' ); //Set the HTTPRequest body req.setBody('{"access_token":"blahblahblahblahblah"}'); Http http = new Http(); try { //Execute web service call here // HTTPResponse res = http.send(req); //Helpful debug messages System.debug('this is a test'); /*System.debug(res.toString()); System.debug('STATUS:'+res.getStatus()); System.debug('STATUS_CODE:'+res.getStatusCode()); */ } catch(System.CalloutException e) { //Exception handling goes here.... } } }
g2wCallout obj = new g2wCallout ();
obj.getWebinars();
Thanks for the help. I created the scheduler class and then used the "Schedule Apex" button in the UI to schedule it to run. However, is there a way to test it "On Demand" so that I don't have to wait for the scheduled job to execute?
Please Mark this as solution if this will help you
Thanks
Amit Chaudhary
System.LimitException: Maximum stack depth reached: 1001
I commented that out and created a test class so that I could run it from the Developer Console to test my API call and now I get this error:
Methods defined as TestMethod do not support Web service callouts, test skipped
How in the world do I test an API callout to see if it's working and what data it's returning?
https://developer.salesforce.com/forums/ForumsMain?id=906F00000008xsuIAA
https://success.salesforce.com/issues_view?id=a1p30000000RZLxAAO
http://salesforce.stackexchange.com/questions/17254/maximum-stack-depth-reached-1001
I hope this will help you !!! Please let me know if you need any help.
Thanks
Amit Chaudhary
amit.salesforce21@gmail.com