What is the Custom Request?
Custom Request refers to customized configurations based on existing commercial interfaces, or encapsulating interfaces to flexibly meet the business needs of the company, in order to achieve a series of operations such as interface fetching, data validation, data analysis, and trigger events.
How to Set the Custom Request?
In the design page of a form, go to Form Properties > Front-End Event > Settings:
Configurations of custom requests are as follows:
What is the Type of Custom Request?
When the trigger field value changes, it will automatically trigger HTTP requests. Currently, there are two types of requests allowed:
GET request: used to acquire data of the server, connecting the parameter (Query or Params) after the URL, for example:
?code=123
POST request: used to send and submit data that can be processed to specified resources.
URL
URL is the server address you want to request. To use a GET request, you need to put parameters to the URL and insert fields into it to assign value to parameters.
Supported fields inserted and corresponding parse value formats are as follows:
Field Name | Format for Parsing Values |
Single Line | Text |
Numerical Control | Number |
Radio | Text |
Checkbox | Text (Comma-separated) |
Single Select | Text |
Multi Select | Text (Comma-separated) |
Date&Time | Text (Time strings of UTC format) |
Member | Text (Member's number-username) |
Department | Text (Department-dept_no) |
Image | Text (Image URL) (Space-separated in case of multiple file URLs) |
Attachment | Text (Attachment URL) (Space-separated in case of multiple file URLs) |
Signature | Text (Attachment URL) (Space-separated in case of multiple file URLs) |
Subfields | Corresponding control format |
Note:
The length of URL depends on the configured server. Too long URL will be truncated, leading to transmission failure of some data parameters.
How to Set the Header and Body?
Select GET, and you can only set the parameter Header.
Select POST, and you can set the parameters Header and Body.
Methods of setting the two parameters are as follows:
Setting Header
You need to set Name and Value under Header on the Header/Body Settings page. You can insert fields into Value and supported fields are the same as those in the section "URL".
Up to 50 headers can be added to each custom request.
Setting Body
Based on different interfaces, you can select JSON or x-www-form-urlencoded under the parameter Body.
You need to set Name and Value under Body on the Header/Body Settings page. You can insert fields into Value and supported fields are the same as those in the section "URL".
Up to 50 bodies can be added to each custom request.
Response Format
There are two response formats: JSON and XML. The methods to parse them are as follows:
Response Format | Parse Method |
JSON | JSON Path |
XML | XPath |
JSON Path
Take the following response as an example:
{ "result": "content of result", "testResult": { "target": "content of target" }, "data": [ { "key": "iPad Air", "value": "2" }, { "key": "iPad Pro", "value": "4" } ], "array": [ "array1", "array2", "array3", "array4", "array5" ] }
Corresponding responses entered by JSON Path are as follows:
Content | First Entering Method | Second Entering Method |
"content of result" | $.result | $["result"] |
"content of target" | $.testResult.target | $["testResult"]["target"] |
"array 1" | $.array[0] | $["array"][0] |
"iPad Pro" | $.data[1].key | $["data"][1]["key"] |
"2" | $.data[1].value | $["data"][1]["value"] |
XPath
Take the following response as an example:
<results> <result>content of result</result> <testResult> <target>content of target</target> </testResult> <data> <key>iPad Air</key> <value>2</value> <key>iPad Pro</key> <value>4</value> </data> <array>array1array2array3array4array5</array> </results>
Corresponding responses entered by XPath are as follows:
Content | How to Enter |
"content of result" | /results/result/text() |
"content of target" | /results/testResult/target/text() |
"array1" | /results/array[1]/text() |
"iPad Pro" | /results/data[2]/key/text() |
"2" | /results/data[1]/value/text() |
How to Set the Response?
You can assign data acquired from the Front-End Event to fields of the form.
1. Click Click to Set under Response Settings:
2. Click Form field and its corresponding response and select fields for which you need to set responses from the drop-down list.
3. To configure assignment rules to response fields, you can assign a value directly or by inserting fields of the form:
How to enter responses depends on the response format. If the response format is JSON, you need to enter responses by JSON Path. If the response format is XML, you need to enter responses by XPath.
4. Fields for which you can set responses and their corresponding parse values are as follows:
Field Name | Format for Parsing Values | Description |
Single Line | Text | / |
Multi Line | Long text | / |
Number | Number | / |
Date&Time | Date&Time | / |
Radio | Text | / |
Checkbox | Text Array | ["Option 1", "Option 2" ,"Option 3"] |
Single Select | Text | / |
Multi Select | Text Array | ["Option 1", "Option 2" ,"Option 3"] |
SubForm fields | Field format | When a subfield triggers the event, response fields must be subfields from the same subform. When a form field triggers the event, you can enter arrays into the subform, with the number of rows in the subform being that in the array. |
Note:
Response records can be added at most 256 KB.
I have finished reading. 🏆
👉I can't wait to USE THE FRONT-END EVENT.
👉I need more HELP in Discord Forum.