-
Notifications
You must be signed in to change notification settings - Fork 1
Script Reference
Joe Bellus edited this page Aug 12, 2017
·
2 revisions
Gives access to get and set configuration variables.
- $variables.get(name) - Returns a variable from the either the local or global configuration. The local configuration is given priority. These values are always returned as strings.
- $variables.set(name, value) - Sets a variable and saves it to the local configuration.
Gives access to the information for the request.
- $request.contentLength - Contains the number of bytes for the request payload. This only applies to POST requests.
- $request.URL - Contains the full URL for the request. This will include any query parameters.
- $request.baseURL - Contains the url for the request without any query parameters.
- $request.setBody(contents) - Sets the request body to a given string. This is only useful for transform scripts.
- $request.headers.get(name) - Returns the header value for a given name.
- $request.headers.set(name) - Sets the header value for a given name.
The response given back from the request.
- $response.body - Contains the response data as a string.
- $response.contentLength - Contains the length, in bytes, of the response.
- $response.headers.get(name) - Returns the header value for a given name.
- $hmac(secret, data) - Returns an HMAC signature for the given data using the given secret key.
json = JSON.parse($response.body)
$variables.set("name", json.data.name)
json = JSON.parse($request.body)
json.data.key_secret = $variables.get("secret")
$request.setBody(JSON.stringify(json)