Answered

Questions on Subject7 REST APIs

https://platform.subject-7.com/api/v2/executions, with this API, I can send an execution set to cloud run from a custom user interface.  I provided the appropriate request body and saw that in the response body, an execution id was returned.  In my case, the execution id was 13
https://platform.subject-7.com/api/v2/executions/13, with this API, information on execution id 13 can be retrieved.   That response body returned the following:

{
 "id" : 13,
 "executionSetId" : 2,
 "executionSetName" : "simulate_authentication",
 "requested" : 1.61298191213E9,
 "executionState" : "COMPLETED",
 "pool" : "default",
 "executionType" : "WEB_SERVICE",
 "executionStatus" : "FAIL",
 "result" : "26/27",
 "browserTypes" : [ "CHROME" ],
 "build" : "2.0.0.1",
 "requester" : "thubbard",
 "speed" : 200
}

1- Is there a “native” way to gauge the status of an execution set while it’s cloud run status is in execution?   Ideally, I’d like to be able to post the execution results as soon as they are available, and not have to “time it” or poll for that data on the client.

2- Is it possible to retrieve more detailed results, similar to the reports received by email?

3- Making the call from the client (custom UI) results in the following error:

Access to XMLHttpRequest at 'https://platform.subject-7.com/api/v2/executions' from origin 'null' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.

I’ve run into errors like this before and ultimately solved them by making a server-to-server call, which bypasses CORS altogether.

Before I take this approach, is there a simpler option, such as adding some sort of flag or property to the request body?

0
1 comment
Avatar
Joseph Hamdan

Hi Thomas,

1. You can create a method using the pseudocode below in the service which works with the API:

public Response waitExecutionCompletion(Long executionId, Conf configuration) {
 // equal 3h
 long timeout = 11000;
 long timeWaiting = 0;
 interval = 20;
 // to avoid endless waiting we use timeout
 while (timeWaiting <= timeout) {
   timeWaiting += interval;
   // wait for 20 seconds and then sand request
   TimeUnit.SECONDS.sleep(interval);
   Response executionResponse = sendGetRequestOnPlatform(executionId, configuration);
   List < String > finalStates = Arrays.asList("COMPLETED", "ERROR", "CANCELLED", "NONE", "GATEWAY_DENIED");
   String executionState = executionResponse.getExecutionState();
   if (executionState != null && finalStates.contains(executionState)) {
     return executionResponse;
   }
 }
 throw new TimeoutException("Execution '" + executionId + "' failed by timeout");
}

then invoke it with:

Response r = waitExecutionCompletion(17777, configuration);

2. Yes, you can use the below endpoints where “891” should contain the execution ID. They will provide a summary in either JSON or HTML format.

https://platform.subject-7.com/api/v1/executionService/reports/executions/891/json

https://platform.subject-7.com/api/v1/executionService/reports/executions/891/html

3. No, there is no such flag or property. Server-to-server call is a solution. If you would like to simplify this approach, please submit a feature request.

Regards,

Subject7 Team

0
Comment actions Permalink

Please sign in to leave a comment.