Validate a script
To validate a script, perform an HTTP POST using the /json{/realm}/scripts
endpoint,
with an _action
parameter set to validate
.
Include a JSON representation of the script and the script language, JAVASCRIPT
, in the POST data.
The value for script
must be in UTF-8 format and then encoded into Base64.
The <session-cookie-name>
header is required and should contain the SSO token of an administrative user who has access to perform the operation.
$ curl \
--request POST \
--header "Content-Type: application/json" \
--header "<session-cookie-name>: AQICS...NzEz*" \
--header "Accept-API-Version: resource=1.1" \
--data '{
"script": "dmFyIGEgPSAxMjM7dmFyIGIgPSA0NTY7Cg==",
"language": "JAVASCRIPT"
}' \
'https://<tenant-env-fqdn>/am/json/realms/root/realms/alpha/scripts/?_action=validate'
{
"success": true
}
If the script is valid the JSON response contains a success
key with a value of true
.
If the script is invalid the JSON response contains a success
key with a value of false
,
and an indication of the problem and where it occurs, as shown below:
$ curl \
--request POST \
--header "Content-Type: application/json" \
--header "<session-cookie-name>: AQICS...NzEz*" \
--header "Accept-API-Version: resource=1.1" \
--data '{
"script": "dmFyIGEgPSAxMjM7dmFyIGIgPSA0NTY7ID1WQUxJREFUSU9OIFNIT1VMRCBGQUlMPQo=",
"language": "JAVASCRIPT"
}' \
'https://<tenant-env-fqdn>/am/json/realms/root/realms/alpha/scripts/?_action=validate'
{
"success": false,
"errors": [
{
"line": 1,
"column": 27,
"message": "syntax error"
}
]
}