GatewayScript (gatewayscript)
Use the gatewayscript policy to execute a specified DataPower® GatewayScript program.
Restriction: The gatewayscript policy can be used only with the DataPower Gateway.
About
You can attach this policy to the following API flows:
- REST
- SOAP
The gatewayscript policy gives you built-in access to the DataPower Gateway module via variable apim.
Properties
The following table lists the policy properties, indicates whether a property is required, specifies the valid and default values for input, and specifies the data type of the values.
| Property label | Required | Description | Data type |
|---|---|---|---|
| Title | No | The title of the policy. The default value is |
string |
| Description | No | A description of the policy. | string |
| Source | Yes | The GatewayScript source code to execute. For example: |
string |
Examples
The following examples show how the full OpenAPI (Swagger 2.0) for the policy looks in the source code.
Example one:gatewayscript:
title: writes message to DataPower log
source: console.debug('Hello World!');Example two:gatewayscript:
title: script written in multiple lines
source: |
var message = [ 'Hello', 'World!' ];
console.debug(message.join(' '));For more code examples, see GatewayScript code examples.Errors
The following error can be thrown while the policy is being executed:
JavaScriptError- a generic error that captures all errors that occur during the execution of the policy.