Skip to main content

Working Logic

Elements of the incoming message (header, parameter, body) are processed with the selected script language and the result is sent to the client.

Read and Write Rules

Changes cannot be made to the original form of the incoming request message, only reading can be done on this data. The response to be returned to the client is prepared within the script.

Creating New Script-2-API

1

Go to Script-2-API Page from Menu

Development → API Creator → Script-2-API item is selected in the main menu.Script-2-API Creation Screen
2

Create New API

The +Create button at the top right of the opened interface is clicked.
3

Fill API Information

Required fields for the new API to be created are filled and the →Save and Next button at the top right is clicked, starting the API creation process.Filling API Information
4

Add Endpoint

After the API is saved, endpoint definition for the API begins. If there is no endpoint, press the add button inside the API for the first time to add, if there is at least one, press the add button that appears in the endpoints section.Adding Endpoint

Endpoint Creation

The following information is entered to define an Endpoint: Endpoint Creation Screen Fields used for endpoint creation configuration are explained below, categorized:

HTTP Method

Field: HTTP MethodHTTP Method is selected for REST APIs: GET, POST, PUT, HEAD, OPTIONS, DELETE, PATCH, TRACE, ALL

Name/URL

Field: Name/URLEndpoint access address. When API Proxy is created, the endpoint is accessed through this address.

Description

Field: DescriptionDefinition information of the API endpoint.

Script Type

Field: Script TypeType of the Script to be written. Can be Javascript or Groovy.

Script

Field: ScriptInformation about the script to be executed.

Variables

Field: VariablesList of read-only and write-only variables that can be accessed in the request and response pipeline. When the relevant variable is clicked, the variable is added to the point where the cursor is located in the Script field.

Try Button

Field: Try ItOpens a new window to allow testing of the script to be executed.

Variables

Various keywords are used for access to message header, parameter, and body parts on script for read and write operations to be performed.
Variables used to access data coming from client to Apinizer:

Header

Variable: requestHeaderMapFromClientData Type: Map<String, String>Operation: ReadUsed to read request headers.

Parameter (URL Parameter)

Variable: requestUrlParamMapFromClientData Type: Map<String, String>Operation: ReadUsed to read URL parameters.

Body

Variable: requestBodyTextFromClientData Type: StringOperation: ReadUsed to read request body.

Message Information (Context)

Variable: contextValuesData Type: StringOperation: ReadUsed to access message information.

Custom Variable

Variable: customVariableMapData Type: Map<String, String>Operation: Read, WriteUsed to read and write custom variables.
Variables used to create data to be sent from Apinizer to client:

Header

Variable: responseHeaderMapToClientData Type: Map<String, String>Operation: WriteUsed to create response headers.

Body

Variable: responseBodyTextToClientData Type: StringOperation: WriteUsed to create response body.

Status Code

Variable: statusCodeToClientData Type: IntegerOperation: WriteUsed to set HTTP status code.

Message Information (Context)

Variable: contextValuesData Type: StringOperation: ReadUsed to access message information.

Custom Variable

Variable: customVariableMapData Type: Map<String, String>Operation: Read, WriteUsed to read and write custom variables.
If script type is Groovy:
  • JsonSlurper when message body is JSON
  • XMLSlurper when message body is XML
Using these makes message processing quite easy.

Creating API Proxy from Script-2-API

After the API’s definitions are completed, it’s time to open this API as an API Proxy.
At least one endpoint of the API created with Script-2-API must exist to create an API Proxy from Script-2-API.
To open Script-2-API as an API Proxy for access, press the Create Proxy button shown in the following visual. Create Proxy Button The API Proxy is created by entering the required fields for the API Proxy on the screen that appears and clicking the Save button. API Proxy Creation Screen After this step, what can be done is the same as the API Proxy document. You can review the API Proxy Creation page for detailed information.
You can create multiple API Proxies for one Script-2-API.

Deploy/Redeploy

You can manage the deployment status of API Proxies created with Script-2-API from the API Proxies page or by selecting the relevant API on the Script-2-API page. To manage from the Script-2-API page, use the window opened by clicking the Manage API Proxies link located at the top of the page. In the opened window, you can perform Deploy, Redeploy, and Undeploy operations for API Proxys created from this API. You can visit our Revision, Deployment, Redeployment, Undeployment pages for more detailed information on this topic. Managing API Proxies After the above operation, confirmation is required. Information about the deployment operation is created and the (Deploy) Deploy button is clicked. Deployment Confirmation Screen
When a new endpoint is added to Script-2-API or changes are made within an endpoint, all API Proxies created from this API must be redeployed for the changes to take effect.
When you add a new endpoint or update an existing endpoint, a notification like the following will appear. Redeployment Notification By saying Redeploy, changes are applied to API Proxies. Redeployment Confirmation Screen After the above operation, confirmation is required. Information about the redeployment operation is created and the (Redeploy) Redeploy button is clicked. From the Script-2-API page, go to the API Proxy by clicking the API Proxy’s name. Going to API Proxy from Script-2-API Page Similarly, to go to the Script-2-API page from the API Proxy page, go by clicking the Script-2-API name in the API Proxy as shown below. Going to Script-2-API from API Proxy Page

Script-2-API Deletion

When a Script API is deleted, all API Proxies connected to it are first removed (undeploy) and then deleted. Script-2-API Deletion Warning