Fetching Data using the POST Method
Web Service Configuration for Fetching Data using the POST Method
The following sample lists the steps to configure the finance Web service for fetching data from it using the POST method.
Details of Sample Web Service
URL: http://localhost:9005/ShreeFinancials/rest/finance/postfetch
Domain name: http://localhost:9005/
Context root: /ShreeFinancials/
Part of Web service URL: /rest and /postfetch
Web service: finance
When you create the connection, ensure that the following fields are configured in the Create New Connection screen for the base URL as follows:
- Authentication Type - No Authentication
- JSON Configuration for Request panel – Please refer JSON Configuration for Request.
To configure the Web service, perform the following steps:
- Perform steps 1 to 3 mentioned in the Web Service Configuration for Fetching Data using the GET Method section.
- In the Create New Data Source page, configure the property fields in the Mandatory Configuration tab as follows:
- Connection Name: This is a non-editable field and displays the unique name provided by you for the connection. For example, WSCONNECTIONPOST.
- Data Source Name: Provide a unique data source name. For example, WEBSERVICEPOSTFETCH.
- Relative part of the URL: Provide the relative URL. For example, ShreeFinancials/rest/finance/postfetch
- Communication App ID: Select the Rest POST JSON Gateway option in this field. For more information on this field, refer the Field Descriptions.
- In the Response Data Mapping panel, provide inputs in the fields as follows:
- Column Root: Provide the hierarchical path to the element that contains the JSON array of data from the Web service response. For example, $.results will be the root element for the finance Web service.
- Value Select Expression: For the finance Web service, productDesc, productCode, transactionAmount, userId, transactionRefNo will be the value select expression.
View Column Id: Provide the column name for the value select expression. For example, Product Description, Product Code, Transaction Amount, User ID, and Transaction Ref. No can be the column names for the value select expressions.
- Same column name must be provided in the Column ID field in App Designer page.
- If the View Column Id is changed for any Value Select Expression in the data source screen later, those columns must be re-mapped in the App Designer page to reflect the changes.
- Click to add more columns.
In the Request JSON Configuration field, specify the JSON model conditions created in the Create New Connection page as shown in the following screen shot:
Refer Passing Data as Header Parameter in Request to get more information on sending data as header parameter to the request.- The query param concept applies only to Web services using the GET HTTP method.
- When the POST method is used for Web service configuration, the payload is sent in the body of the request in JSON format.
The following screen show the Request JSON Configuration field with the model combinations:
When you hover over the confirmed JSON model conditions, the following icons can display:
: To enable or disable a field in the JSON model condition.
: To add a field in the JSON model condition.
: To delete the JSON Model condition from the Request JSON Configuration field.
In the Create New Data Source screen, configure the property fields in the Additional Configuration tab as follows:
- Service Type: The field is auto-populated with the POST option when the Rest POST JSON Gateway option is selected in the Communication App ID field. For more information on this field, refer the /wiki/spaces/ICPI/pages/726958425.
- Instruction Class: This field is auto-populated with the default Java instruction class com.intellectdesign.canvas.defaultviews.DefaultRestServiceInstruction. For more information on this field, refer the /wiki/spaces/ICPI/pages/726958425.
- Click Save.
Once the data source is successfully created for the connection, the data source can be linked to View > App. For more information, refer Designing Apps using App Designer.
The following screen shots are of the Shree Finance Details app in the Modelhouse application displaying data fetched from the finance web service with filtering enabled for the fields: