Synthetic Classic has reached end of support and is no longer available. Existing Synthetic Classic customers have been upgraded to the all-in-one Dynatrace software intelligence platform.

Validate against an object response code

Custom scripting can be used in a test to validate against a specific object's response code.

Create an event hook for the object you want to validate. Use code similar to this example in a Custom action:

var getUrl = new AddEventHookCommand({
"eventType": "replyReceived",
"name": "directNavigate",
"handler":"if(response.getRequest().getUrl().indexOf('') != -1){if (response.status == '200'){script.steps[0].actions[3].type = 'do not execute';}}"

In indexOf(''), replace the example object with the object for which you want to capture the response code.

In (response.status == '200'), replace the example response code 200 with the response code you want to use for validation.

Whenever this object is found during the course of the script, the handler code will run. The example code sets an action not to execute during the test if the response code is 200.

The attached script shows all the pieces working together: ResponseCodeSample.gsl.