API

You can use this task to configure an API on the component or element. When you configure the API, you define the request and response parameters to exchange the required data between the front-end application and server.

You can configure the API in the following scenarios:

  • Get the data from the front-end application and store it in server
  • Get the data from the server and then display it in the front-end application
  • Enable the navigation between multiple pages in the application
  • Delete the data from the data storage
  • Update the data in the server
  • Implement a specific behavior in the application

To configure the API task:

  1. In the Events dialog box, scroll down.
  2. Under Add Tasks, click the Select Task list, and then select DOWNLOAD_AS_ZIP.
  3. Click Add Task Config, and the Add Task dialog box opens.
  4. In the Add Task dialog box, click the Configuration area to expand it.
  5. In the Configuration area, perform the functions as follows:
PropertyDescription
NameIn this box, enter the name of API (for example:- AUTH_VAHANA). This API must be published on the vConnect portal before you configure the API task.
Success Key PathIn this field, enter a data path. This data path will store the status code (for example:- y) that the API will return after it successfully performs the intended function. You can define the data path as follows:
#Sample Data Path
getVal(“tempObject.status”)
Success ValueIn this field, enter the status code (for example:- y) that the API will return after it performs the intended function successfully.
Failure Message PathIn this field, enter the data path that will store the failure message. After the API fails to perform the intended function, it will display this failure message. You can define the failure message data path as follows:
#Sample Failure Message Path
getVal(“tempObject.errmsg”)

In the data path, the errmsg parameter will store the failure message.
Run on BackgroundIf you click this check box, the application will execute the next task and wait for the API’s response in the background.
Cast to JSONIf you click this check box, the API task will parse the data before it sends it to the destination. During parsing the data, if it finds the data in string format, the Cast to JSON feature will convert the data into JSON format.
  1. After you enter the service-related details, define the request type key/value pair in the C2S 1 area as follows:
PropertyDescription
Key NameIn this field, enter the request type key or parameter (for example:- proposalId).
TypeClick this list and then select one of the following values:
1. Fixed
Select this option to store the value in the key in string format.


2. JSON
Select this option to store the value in the key in JSON format.
Data PathIn this field, enter a data path that contains the request parameter. You can define the data path as follows:

# Sample Data Path
getVal(“1683530513298967.proposal_id”)

In this data path, the 1683530513298967 value is the form ID of a “Form” component. When the related API is invoked, it gets the proposal ID from the proposal_id parameter.
  1. To define another request type key or parameter, click the Add C2S 2 tab.
  2. After you define the request type key, define response type keys in the S1C 2 area as follows:
PropertyDescription
Key NameIn this field, enter the response type key as follows:

# Sample Key Name:
getVal(“tempObject.retrigger.result”)

When the API task is executed, the API returns the response and then stores it in the result key in the retrigger object.
TypeClick this list and then select one of the following options:
1. FIXED
Select this option to store the value (for example:- 1234) in the key in string format.

2. RANDOM
Select this option to store a unique six digits random number. The API automatically generates the random number and then stores in the parameter.

3. USER_OBJECT


4. JSON
Select this option to store the value in the configured JSON path.
Data PathIn this field, enter a data path that will store the response. You can define the data path as follows:

# Sample Data Path
getVal(“RETRIGGER.URL”)

In the data path, the RETRIGGER.URL object will store the response data. When the API task is executed, the service will get the data from the RETRIGGER.URL object and store it in the result key in the retrigger object.
Was this article helpful?
YesNo