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
Shilpa KambleShilpa Kamble 

Not getting response of tooling API from Anonymous window.

Hi,

I am trting to use the tooling api, I want to check the result if I call the method from Anonymous window of developer console, I am not getting the response.

Please check the below code.
public class APIHandler{

    public void executeREST(){
        system.debug('In executeREST');
        HttpRequest req = new HttpRequest();
        req.setHeader('Authorization', 'Bearer ' + UserInfo.getSessionID());
        req.setHeader('Content-Type', 'application/json');
        req.setEndpoint('http://ap5.lightning.force.com/services/data/v42.0/tooling/sobjects/');
        req.setMethod('GET'); 
        
        Http h = new Http();
        HttpResponse res = h.send(req);
        system.debug('req='+req);
        system.debug('response===='+res.getBody()); 
    }
}
and the code for testing is as below:
APIHandler obj = new APIHandler();
obj.executeREST();
but I am not getting the response, please guide me.

Thanks in advance!

 
Rahul KumarRahul Kumar (Salesforce Developers) 
Hi Shilpa Kamble, hope it helps.

Please mark it as best answer if the information is informative.so that question is removed from an unanswered question and appear as a proper solution.

Thanks
Rahul Kumar
Shilpa KambleShilpa Kamble
@Rahul, I am not getting any error or error code