Add an API to a script
By adding an API to a script, you can perform basic API operations that depend on the definition of your chosen API. You can add several various API request methods to a script but can only add individual API request methods one at a time.
Prerequisites
-
You have created a new script or imported an existing one.
-
The script is in edit mode. An open lock icon for the script in the Application component pane indicates that you have opened the script and can edit it. If the script is in display mode, right-click the script and select Edit.
Procedure
-
Drag and drop an API request method from the Reusable components pane into the script in the Application components pane.
-
To perform an API call, right-click a code line in the Script editing pane and select Code Snippets.
Result: The Code Snippets dialog opens. All generated code snippets for each API you have included in the script are shown in the APIs category.
You can extend the options object sent to the API request method with the supported property axiosConfig
. TheaxiosConfig
object supports all properties supported by the config object used in the axios module, for example, to set theresponseEncoding
of the request sent from the Neptune DXP - Open Edition server. -
Select Copy.
Result: The selected API is inserted directly into the Script editing pane.