Description

The SaveScript API allows the Account Owner to create or update a Script.

  • SaveScript API could be called to import a system script; by passing its name and its content in parameters (system script's name can be gotten from the ListScripts response, and its content can be gotten from the GetScript response). And note that whenever the application owner attempts to update a script that is found in both application and system libraries, only the private script will be updated, the system script will never be affected.

Script template

 

<script>
	<scriptACL>
		<execute>nobody</execute>
		<read>nobody</read>
		<write>nobody</write>
	</scriptACL>
	<code>
		<![CDATA[
			//Your code goes here 
		]]>
	</code>
</script>

Specific Request Parameters

(Refer to Common Request Parameters)

NameDescriptionRequiredDefaultPossible Values

apsdb.scriptName

Represents the full script name that can consists of up to 5 folders and the script file name separated by the character '/'.

e.g., application/provisioning/user/registration

In the example above the registration script is saved under the three folders application > provisioning > user

Yes 
  • Must begin with an alphabetic character.
  • Must end with an alphanumeric character or underscore (_).
  • Can contain alphanumeric characters, underscores (_) and periods (.).
  • Cannot have two or more consecutive periods.

The full script name including any folders must be minimum 3 characters and maximum 128 characters long; it should respect the following regular expression ^([A-Za-z][A-Za-z0-9_])( ([A-Za-z0-9_])+(\Q.\E) )*([A-Za-z0-9_]+)

apsdb.newScriptName

The new name of the script (in case of an update).

No

  

apsdb.update

Specifies whether an update is requested or not.

No

false

true

false 

apsdb.script

The XML definition of the script containing the ACLs and the script code.

No

 

 

Specific Logical Errors

(Refer to Common Logical Error Codes)

 

ErrorMessageStatus Code

SCRIPT_NAME_REQUIRED

 

400

INVALID_SCRIPT_NAME

Invalid script name [scriptName]

400

PERMISSION_DENIED

 

403

SCRIPT_ALREADY_EXISTS

 

400

INVALID_SCRIPT

 

400

PARAMETER_REQUIRED

 

400

 

Examples

Sample Request

Request URL: http://sandbox.apstrata.com/apsdb/rest/[authenticationkey]/SaveScript?apsws.time=[timestamp]&apsws.authSig=[signature]

POST parameters:

apsdb.scriptName=[script_name]
apsdb.script= [script_content]

Sample XML Response

Success XML:

<response xmlns="http://www.apstrata.com/services/schemas/apstrata_database_response.xsd">
    <metadata>
        <requestId>xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx</requestId>
        <status>success</status>      
    </metadata>
	<result>
		<localSHA>eb224e0951e68d0a2a227db556041c655c0e17ed</localSHA>
		<metadataLocalSHA>cebbbe640e8f1510069b2fc77494db6ef7b11a36</metadataLocalSHA>
	</result>
</response>

Failure XML:

<response xmlns="http://www.apstrata.com/services/schemas/apstrata_database_response.xsd">
    <metadata
        <requestId>xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx</requestId>
        <status>failure</status>
        <errorCode>[errorCode]</errorCode>
        <errorDetail>[failMsg]</errorDetail>
    </metadata>
</response>

Sample JSON Response

{
	"response": { 
		"metadata": { 
			"requestId": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", 
			"status": "success" 
		},
		"result":{
			"localSHA":"eb224e0951e68d0a2a227db556041c655c0e17ed",
			"metadataLocalSHA":"cebbbe640e8f1510069b2fc77494db6ef7b11a36"
		}
	}
}