Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
String baseURL = 'https://' + System.URL.getSalesforceBaseUrl().getHost();
string queryStr = 'SELECT+NumLinesCovered,ApexClassOrTriggerId,ApexClassOrTrigger.Name,NumLinesUncovered,Coverage+FROM+ApexCodeCoverageAggregate';
String ENDPOINT = baseURL + '/services/data/v40.0/tooling/';
HttpRequest req = new HttpRequest();
req.setEndpoint(ENDPOINT + 'query/?q=' + queryStr);
req.setHeader('Authorization', 'Bearer ' + UserInfo.getSessionID());
req.setHeader('Content-Type', 'application/json');
req.setMethod('GET');
req.setTimeout(80000);
Http http = new Http();
HTTPResponse res = http.send(req);
System.debug(res.getBody());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.