Testing the response code of a request

This sample code is an event hook that looks for a specific request and captures the response code of that request. In this sample, we are capturing the response of a specific REST API query, and checking to make sure it did not return a 500 Server Error.

A demo script can be downloaded here as well: ResponseCodeSample.gsl.

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