Scripts
You can interact with the script service over REST, as shown in the following table:
URI | HTTP Operation | Description |
---|---|---|
/openidm/script?_action=compile |
POST |
Compiles a script, to validate that it can be executed. Note that this action compiles a script, but does not execute it. A successful compilation returns |
/openidm/script?_action=eval |
POST |
Executes a script and returns the result, if any. |
The following example compiles, but does not execute, the script provided in the JSON payload:
curl \ --header "X-OpenIDM-Username: openidm-admin" \ --header "X-OpenIDM-Password: openidm-admin" \ --header "Accept-API-Version: resource=1.0" \ --header "Content-Type: application/json" \ --request POST \ --data '{ "type": "text/javascript", "source": "source.mail ? source.mail.toLowerCase() : null" }' \ "http://localhost:8080/openidm/script?_action=compile" True
The following example executes the script referenced in the file
parameter, with the provided input:
curl \ --header "X-OpenIDM-Username: openidm-admin" \ --header "X-OpenIDM-Password: openidm-admin" \ --header "Accept-API-Version: resource=1.0" \ --header "Content-Type: application/json" \ --request POST \ --data '{ "type": "text/javascript", "file": "script/autoPurgeAuditRecon.js", "globals": { "input": { "mappings": ["%"], "purgeType": "purgeByNumOfRecordsToKeep", "numOfRecons": 1 } } }' \ "http://localhost:8080/openidm/script?_action=eval" "Must choose to either purge by expired or number of recons to keep"