How to get data from external APIs
How to provide other applications with real-time information through webhook
Constant
Template
External URL in Page Data Source
Workflow Webhook
Constant is created at app-level.
Set of Constants can be used in Template, External URL and Webhook. Both Authentication and Data Request are supported.
Set of Constants can be used in:
URL Editor
Key Value Pair of Query, Header and Content
For any Constant created, the Constant ID must fulfill the following rules:
Cannot be empty
Must be unique (case insensitive)
Only A-Z, a-z, 0-9, -, _ are allowed
Cannot start or end with “-”
No space is allowed
20 characters max.
Values of Constants will not be brought to other environment(s) through deployment and users can edit and encrypt the value of Constants in other environment(s), unless it is locked in the developing environment.
The value of Constant can be encrypted. The action of encryption is not reversible, that means it cannot be decrypted and shown in plain text after encrypted.
At App Management > Developing Environment, on the side menu, click External URL Template.
2. Go to the tab ‘Constant’.
3. Click the ‘+’ button to create a new constant.
4. Fill in the Constant ID and Value, then click '' to confirm.
Templates are created at app-level.
Templates can be used while setting up External URL Data Source in pages or Webhooks in workflows.
At App Management > Developing Environment, on the side menu, click External URL Template.
2. Go to the tab ‘Template’, click the ‘+’ button to create a new template.
3. Fill in the ‘TEMPLATE NAME’.
4. In the 1st step ‘Authentication’, you may select the way of Authorization and set it up if needed, then click ‘Continue’. (You may go to Step.5 directly if ‘No Authorization’ is selected.)
a. For OAuth authorization, click ‘Set Up’ to open the URL Editor.
b. Click ‘+ URL Setting’ and setup the URL of authentication, then click ‘OK’
There is a preview for the URL after adding a component.
URL Editor supports the following components:
Text
Text inputted by App Designer
Constant
Constant created in Constant List
Variable
System Widgets
Widgets
(only for External URL in Page Data Source and Workflow Webhook)
Widgets on the form / page
c. Set ‘Timeout (s)’ and ‘Token Key’.
Input the name of the returned token key and the key value will be stored to the System Variable ‘$OToken’.
If there are no values returned within the Timeout set, Dragonce will retry to get the value again.
d. Input Key Value Pair for Query, Header and Content, then click ‘Continue’.
Query is using “GET method”, and that for Content is “POST method”.
Value can be encrypted in design time for data protection. The action of encryption is not reversible, that means it cannot be decrypted and shown in plain text after encrypted.
The Key Value Pair supports the following components:
Constant
Constant created in Constant List
Variable
System Widgets
Widgets
(only for External URL in Page Data Source and Workflow Webhook)
Widgets on the form / page
5. In the 2nd step ‘Data Request’, click ‘Set Up’ to set up the URL.
6. Set up the URL, then click ‘OK’.
URL Editor supports the following components:
Text
Text inputted by App Designer
Constant
Constant created in Constant List
Variable
System Widgets, including Token Key widget
Widgets
(only for External URL in Page Data Source and Workflow Webhook)
Widgets on the form / page
7. Input Timeout and Key and Value for Query, Header, and Content, then Click ‘Continue’.
Query is using “GET method”, and that for Content is “POST method”.
Value can be encrypted in design time for data protection. The action of encryption is not reversible, that means it cannot be decrypted and shown in plain text after encrypted.
The Key Value Pair supports the following components:
Constant
Constant created in Constant List
Variable
System Widgets, including Token Key widget
Widgets
(only for External URL in Page Data Source and Workflow Webhook)
Constant created in Constant List
8. In the 3rd step ‘Data Format’, input ‘Data Key’. Select the ‘Data Type’ and click ‘Continue’.
The External URL only supports JSON format as return.
The Data Type refers to the widget type of Dragonce.
Click the ‘Required’ checkbox to do checking on the returns.
9. In the 4th step ‘Error Handling’, enter the number of Retry Count. You may skip the error checking or customize the error messages for each error type.
Retry Count is applicable to both OAuth and Data Request.
Error handling is available for the following error types:
Network Error
Timeout
HTTP error (400 or 500 series)
Empty Response
No response from the external API for Authentication or Data Request
Missing Token
No access token is returned in Authentication
This error will NOT be hit if the external data source is set as No Authorization
No Value for Constant
Any constant used in the external data source does not have value
Data Key Error
Missing data key from the external API
Wrong data type for any ‘required’ data key
If an empty string is returned for a data key and its data type is string, it will not be regarded as wrong data type. However, if the data type is integer/decimal/user picker, it will be regarded as wrong data type
10. Click ‘Test’ to perform testing on the settings.
11. Click ‘Start’ to try to retrieve data through API calls.
12. Close the window after successful retrieval of values.
13. Click ‘Finish’ to complete the settings.
In the Page Builder, click the ‘Page Data Source’ icon.
2. Click ‘Add Data Source’.
3. In the 1st step ‘Data Source’, input the name of Label and choose ‘External URL’ for Data Source.
4. Click ‘Set Up’ next to the Data Source.
5. Select any pre-built template to copy.
Settings from the selected template will overwrite the current settings.
6. If you want to create a new setting instead of using template, please go back to 2. Template > 2.2 Detailed Steps > Step.4-13.
[Caution: All request parameters set in ‘External URL’ will be considered as Required.]
7. Click ‘Continue’.
8. In the 2nd step ‘Record Filter’, click ‘Continue’.
9. In the 3rd step ‘Mapping’, mouse over the ‘Current Page Widget’ to map source data widget with widgets on the page.
10. Click the ‘Finish’ button to complete the setup.
In the Workflow Builder, click the ‘Workflow Webhook’ icon.
2. Click ‘+ New Generation’.
3. Click ‘Webhook Settings’.
4. Select any pre-built template to copy.
Settings from the selected template will overwrite the current settings.
5. If you want to create a new setting instead of using template, please go back to 2. Template > 2.2 Detailed Steps > Step.4-8.
[Caution: All request parameters set in ‘Webhook’ will be considered as Optional.]
a. In the 4th step ‘Error Handling’, enter the number of Retry Count, decide whether to pass hard code value to current form widget when there is an error i.e. Network Error / Empty Response / Missing Token / No Value for Constant / Data Key Error. Then, click ‘Finish’.
6. After setting up the URL and adding the data, mouse over the ‘Current Page Widget(s)’ to map data with widgets of Dragonce.
7. Click the ‘Submit’ button to complete the setup.
This is the weather forecast that we would like to get from ‘Yahoo! Weather API’.
Run time result:
The example below shows part of the returned JSON from the API. (some data is omitted)
{
"query":{
"count":1,
"created":"2018-07-11T12:41:27Z",
"lang":"en-US",
"results":{
"channel":{
"description":"Yahoo! Weather for Hong Kong, HK",
"language":"en-us",
"lastBuildDate":"Wed, 11 Jul 2018 08:41 PM HKT",
"ttl":"60",
"location":{
"city":"Hong Kong",
"country":"Hong Kong",
"region":" HK"
},
"wind":{
"chill":"86",
"direction":"195",
"speed":"14"
},
"atmosphere":{
"humidity":"68",
"pressure":"994.0",
"rising":"0",
"visibility":"16.1"
},
"astronomy":{
"sunrise":"5:47 am",
"sunset":"7:11 pm"
},
"image":{
"title":"Yahoo! Weather",
"width":"142",
"height":"18",
"link":"http://weather.yahoo.com",
"url":"http://l.yimg.com/a/i/brand/purplelogo//uh/us/news-wea.gif"
},
"item":{
"title":"Conditions for Hong Kong, HK at 08:00 PM HKT",
"lat":"22.283319",
"long":"114.158722",
"link":"http://us.rd.yahoo.com/dailynews/rss/weather/Country__Country/*https://weather.yahoo.com/country/state/city-2165352/",
"pubDate":"Wed, 11 Jul 2018 08:00 PM HKT",
"condition":{
"code":"26",
"date":"Wed, 11 Jul 2018 08:00 PM HKT",
"temp":"87",
"text":"Cloudy"
},
"forecast":[
{
"code":"30",
"date":"11 Jul 2018",
"day":"Wed",
"high":"90",
"low":"81",
"text":"Partly Cloudy"
},
{
"code":"4",
"date":"12 Jul 2018",
"day":"Thu",
"high":"87",
"low":"83",
"text":"Thunderstorms"
},
{
"code":"4",
"date":"13 Jul 2018",
"day":"Fri",
"high":"85",
"low":"81",
"text":"Thunderstorms"
},
{
"code":"4",
"date":"14 Jul 2018",
"day":"Sat",
"high":"84",
"low":"81",
"text":"Thunderstorms"
},
{
"code":"47",
"date":"15 Jul 2018",
"day":"Sun",
"high":"85",
"low":"82",
"text":"Scattered Thunderstorms"
},
],
}
}
}
}
}
Build the page with the following configurations.
1
Formatted Container
Today
General:
Position, Size and Layout >Element Allocation > ‘Full Width’
2
Input Box
Date.0
General:
Basic >Display Text > ‘Date’
3
Input Box
Forecast.0
General:
Basic >Display Text > ‘Weather Forecast’
4
Input Box
High.0
General:
Basic >Display Text > ‘Max. Temp (°F)’
5
Input Box
Low.0
General:
Basic >Display Text > ‘Min. Temp (°F)’
6
Formatted Container
Tomorrow
General:
Size and Layout >Element Allocation > ‘Full Width’
7
Date.1
Tomorrow
General:
Basic >Display Text > ‘Date’
8
Input Box
Forecast.1
General:
Basic >Display Text > ‘Weather Forecast’
9
Input Box
High.1
General:
Basic >Display Text > ‘Max. Temp (°F)’
10
Input Box
Low.1
General:
Basic >Display Text > ‘Min. Temp (°F)’
11
Formatted Container
2 days later
General:
Position, Size and Layout >Element Allocation > ‘Full Width’
12
Input Box
Date.2
General:
Basic >Display Text > ‘Date’
13
Forecast.2
Forecast.2
General:
Basic >Display Text > ‘Weather Forecast’
14
Input Box
High.2
General:
Basic >Display Text > ‘Max. Temp (°F)’
15
Input Box
Low.2
General:
Basic >Display Text > ‘Min. Temp (°F)’
16
Formatted Container
3 days later
General:
Position, Size and Layout >Element Allocation > ‘Full Width’
17
Input Box
Date.3
General:
Basic >Display Text > ‘Date’
18
Input Box
Forecast.3
General:
Basic >Display Text > ‘Weather Forecast’
19
Input Box
High.3
General:
Basic >Display Text > ‘Max. Temp (°F)’
20
Input Box
Low.3
General:
Basic >Display Text > ‘Min. Temp (°F)’
2. In the Page Builder, click the ‘Page Data Source’ icon.
3. Click ‘Add Data Source’.
4. In the 1st step ‘Data Source’, input ‘HK Weather’ as the name of Label and choose ‘External URL’ for Data Source.
5. Click ‘Set Up’ next to the Data Source.
6. In the 1st step ‘Authentication’, click ‘Continue’.
7. In the 2nd step ‘Data Request’, click ‘Set Up’ to set up the URL.
8. Click ‘+ URL Setting’ to add a new URL.
9. Copy this link:
and paste it as Text and click ‘Apply’ to confirm. Then, click ‘OK’
10. Click ‘Continue’.
11. In the 3rd step ‘Data Format’, click ‘+ Key Value Pair’ to add new Data Key and corresponding Data Type.
12. Fill in the Data Key and select corresponding Data Type following the table below:
query.results.channel.item.forecast.0.date
String
query.results.channel.item.forecast.1.date
String
query.results.channel.item.forecast.2.date
String
query.results.channel.item.forecast.3.date
String
query.results.channel.item.forecast.0.text
String
query.results.channel.item.forecast.1.text
String
query.results.channel.item.forecast.2.text
String
query.results.channel.item.forecast.3.text
String
query.results.channel.item.forecast.0.high
String
query.results.channel.item.forecast.1.high
String
query.results.channel.item.forecast.2.high
String
query.results.channel.item.forecast.3.high
String
query.results.channel.item.forecast.0.low
String
query.results.channel.item.forecast.1.low
String
query.results.channel.item.forecast.2.low
String
query.results.channel.item.forecast.3.low
String
13. Click ‘Continue’.
14. In the 4th step ‘Error Handling’, click ‘Test’ to perform testing on the settings.
15. Click ‘Start’ to try to retrieve data through API call.
16. Close the window after successful retrieval of values.
17. Click ‘Finish’ to complete the settings.
18. Click ‘Continue’.
19. In the 2nd step ‘Record Filters’, click ‘Continue’.
20. In the 3rd step ‘Mapping’, map the following Source Data Widget with the Current Page Widget:
query.results.channel.item.forecast.0.date
Date.0
query.results.channel.item.forecast.1.date
Date.1
query.results.channel.item.forecast.2.date
Date.2
query.results.channel.item.forecast.3.date
Date.3
query.results.channel.item.forecast.0.text
Forecast.0
query.results.channel.item.forecast.1.text
Forecast.1
query.results.channel.item.forecast.2.text
Forecast.2
query.results.channel.item.forecast.3.text
Forecast.3
query.results.channel.item.forecast.0.high
High.0
query.results.channel.item.forecast.1.high
High.1
query.results.channel.item.forecast.2.high
High.2
query.results.channel.item.forecast.3.high
High.3
query.results.channel.item.forecast.0.low
Low.0
query.results.channel.item.forecast.1.low
Low.1
query.results.channel.item.forecast.2.low
Low.2
query.results.channel.item.forecast.3.low
Low.3
21. Click the ‘Finish’ button.