Created
June 19, 2016 10:06
-
-
Save tyoshikawa1106/5ab250349f7026ca3428525acc04136a to your computer and use it in GitHub Desktop.
開発者コンソールから動かすTooling API
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
String requestBody = '{'; | |
requestBody += ' "tests": ['; | |
requestBody += ' {'; | |
requestBody += ' "classId": "01p10000001lEPV",'; | |
requestBody += ' "testMethods": ["Summer16ApexDemoControllerTest1","doSerializeJsonTest1", "doSerializePrettyJsonTest1"]'; | |
requestBody += ' }'; | |
requestBody += ' ]'; | |
requestBody += '}'; | |
System.debug(requestBody); | |
Http http = new Http(); | |
HttpRequest req = new HttpRequest(); | |
req.setHeader('Authorization', 'Bearer ' + UserInfo.getSessionId()); | |
req.setHeader('Content-Type', 'application/json'); | |
req.setBody(requestBody); | |
req.setEndpoint(URL.getSalesforceBaseUrl().toExternalForm() + '/services/data/v37.0/tooling/runTestsAsynchronous'); | |
req.setMethod('POST'); | |
HttpResponse res = http.send(req); | |
System.debug(res); | |
String result = res.getBody(); | |
System.debug(result); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment