Skip to content

Execution

Control collection-run and workflow playback flow from pre- and post-request scripts.

Collection helpers apply during a collection run. Workflow helpers apply while a workflow is playing a request.send action; outside a workflow they are no-ops. For recording, editing, and running workflows in the app or CLI, see Workflows.

hc.execution.setNextRequest(name)

Available since v2.0.0

Signature:(name: string | null) => void

After the current request finishes, jump to the saved request with that name in the run order. Pass null to stop the run. When the name does not match any request in the run, HarborClient falls back to the next request in order.

javascript
if (hc.response.code === 401) {
  hc.execution.setNextRequest("Refresh Token");
}

hc.execution.skipRequest()

Available since v2.0.0

Signature:() => void

Skip the HTTP send for the current request. Pre-request scripts still run; post-request scripts do not run. On a manual send outside the collection runner, the active tab shows a skipped response instead of sending HTTP. When a pre-request script also called hc.send or hc.sendJSON, that override becomes the displayed response (instead of the empty skipped placeholder).

javascript
if (!hc.request.variables.get("runThisStep")) {
  hc.execution.skipRequest();
}

hc.execution.workflowNextAction(actionId)

Available since v2.0.0

Signature:(actionId: string) => void

After the current workflow action finishes, jump to the action whose UUID matches actionId. When the UUID does not match any action in the workflow, HarborClient falls forward to the next action in order. No-op when the script is not running inside a workflow.

javascript
if (hc.response.code === 401) {
  hc.execution.workflowNextAction("aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee");
}

hc.execution.workflowSkipAction()

Available since v2.0.0

Signature:() => void

Skip the remainder of the current workflow action and advance to the next. When called from a request.send pre-request script, also skips the HTTP send and post-request scripts (same send effect as skipRequest). No-op when the script is not running inside a workflow.

javascript
if (!hc.request.variables.get("runThisStep")) {
  hc.execution.workflowSkipAction();
}