What is a HTTP Action?
HTTP actions perform HTTP(S) requests to external APIs and return the response.
Creating HTTP Actions
Expand |
---|
|
Iframe |
---|
allowfullscreen | true |
---|
src | https://www.youtube.com/embed/-sDFQV47nDU?si=-gsTkv-OJ8ki4uLM?&rel=0&ytp-pause-overlay |
---|
width | 680 |
---|
align | middle |
---|
height | 400 |
---|
|
|
Creating HTTP Actions
Iframe |
---|
allowfullscreen | true |
---|
src | https://www.youtube.com/embed/zSu7S7vpvwE?si=FAEwf0kAkmIYirVA?&rel=0&ytp-pause-overlay |
---|
width | 680 |
---|
align | middle |
---|
height | 400 |
---|
|
- Click and drag the icon from the toolbar onto the canvas
- Enter a name for the HTTP action, then select Create Action
- In the HTTP action
Insert excerpt |
---|
| _property_settings |
---|
| _property_settings |
---|
nopanel | true |
---|
|
on the right, populate the following details:
Excerpt |
---|
|
Field | Description | Example Value |
---|
Name | Name given to the HTTP Node. This will be displayed on the Actionflow canvas. | BankHolidays | HTTP Method | The HTTP method. A drop-down field containing: GET, POST, GET or POST, |
|
HEAD DELETE, other. If other is specified a text box will allow the entering of a custom value which is not empty and contains only uppercase lettersPATCH. | Get | URL Template | A template that computes the URL of the request. |
|
Expects literal values or expressions encapsulated within ${} syntax, for example ${in.MyValue}
.If using the URL to pass across parameters, care should be taken to ensure that the values are appropriately URL encoded. | https://www.gov.uk/bank-holidays.json
https://server/phixflow/api/1/action/App/Api/trigger?field=abc | Body Template | Optional. If this is provided then it is used to carry the HTTP request data. If a body is provided then usually Content-Type and Content-Length headers lines specify the nature of the body associated. In PhixFlow if this evaluates to whitespace only then it is not included in the request. The body expects literal values, or expressions encapsulated within ${} syntax, for example ${in.MyValue} . | //JSON Example
{
"Industry" : "${in.Industry}"
}
| Error Expression | Optional. A JEP expression to determine if the response is an error and if so |
|
sent error outputError Output Connection Point. The expression will have access to the input record (in) and the mapped output response (_result). | _result.isError | Log Traffic | Toggle on Insert excerpt |
---|
| _toggle_on |
---|
| _toggle_on |
---|
nopanel | true |
---|
|
|
|
to logs to log the response of the HTTP request in the System Console, e.g. see an error returned, or see the output before specifying a path. Use this when testing but switch off once testing is completed. | Insert excerpt |
---|
| _toggle_on |
---|
| _toggle_on |
---|
nopanel | true |
---|
|
| Maximum HTTP Log Length | Available if Log Traffic is toggled on Insert excerpt |
---|
| _toggle_on |
---|
| _toggle_on |
---|
nopanel | true |
---|
| .Restricts the size of the log traffic. | 1000 | Use Raw URL | Toggle on Insert excerpt |
---|
| _toggle_on |
---|
| _toggle_on |
---|
nopanel | true |
---|
| to send the URL Template value in exactly the format it is provided to the HTTP Node.If toggled off Insert excerpt |
---|
| _toggle_off |
---|
| _toggle_off |
---|
nopanel | true |
---|
| PhixFlow will transpose values to form a valid URL, such as replacing spaces with %20. | Insert excerpt |
---|
| _toggle_on |
---|
| _toggle_on |
---|
nopanel | true |
---|
|
| HTTP Configuration | See HTTP Configuration |
|
4.
Insert excerpt |
---|
| _finish |
---|
| _finish |
---|
nopanel | true |
---|
|
all settings5. Hover over the action on the canvas to see the output connection points
Output Connection Points
A HTTP action has two outputs. A HTTP request will be triggered for each input record and generate one output record, which will be sent on either the out or error output.
The response from the server (headers and body) will be treated as the result record..
Output Connection Point | Description |
---|
Out | Contains the resulting record of the request. |
Error | Contains the resulting record of the request where it satisfies the error expression specified on the HTTP Node. |
The output records contain the attributes specified by the output connection point, successful . Successful records are passed down the out connection point and records containing an error are passed down the error connection point. The structure of the records by default are as follows:
status message- statusMessage: The returned status message, for example,
OK
|
Image Removed
Adding and Editing
To add a new output connection point, click the - cookies: Returns an array of cookie name, domain, etc.
- isError: Returns true if the response contains a 400+ error code
- headers: Returns an array of header values
- statusFamily: Returns the status family code, for example if status returns
202 , then statusFamily will return 200 - transmissionError: Returns true if the request failed, e.g. timed out
|
Image Added
addIconaddIconAttributes | Contains the attributes which hold the values returned by the Output Connection Point. Result values are obtained using the keyword _result followed by the attribute name. | _result.status
icon, see Connection Points HTML Comment |
---|
|
ZB I couldn't create a new output connection point? |
Configuration
The configuration of each output connection point is identical:
Field | Description | Example |
---|
Name | Name of the output | out |
Output Type | A drop-down field containing: String, Raw Data, JSON. | String |
Skip Invalid Records | Skip attributes which are considered invalid. | Enabled |
Default Charset | A drop-down field containing character set options, including utf-8. | utf-8 |
Path | The JSON path to apply. If empty this will default to '$' which matches the entire object. | // $ returns everything, this syntax traverses down two levels using two full // stops. $..events
|
JSON Lenient | When enabled this removes JSON specification restrictions, allowing for a degree of leniency in malformed JSON data. When disabled the JSON will be treated strictly. | Enabled |
s are used to transmit values within a URL. They are automatically added to the end of the URL the HTTP action is calling, with the format: ?param1Name=param1Value¶m2Name=param2Value - The Parameter values are automatically encoded into a format suitable for passing via a URL
- Refer to attributes mapped into the HTTP action using the syntax: ${ConnectorName.AttributeName} in the Expression
- The parameter names must match those set on the API
|
- See below example where an Actionflow HTTP action is calling a PhixFlow API Endpoint
Section |
---|
Column |
---|
Action Image Added |
Column |
---|
Insert excerpt |
---|
| _actionflow_api_endpoint |
---|
| _actionflow_api_endpoint |
---|
name | text |
---|
nopanel | true |
---|
| Input Parameters
Image Added |
|
Headers are typically used to specify information for the request, such as character sets, session tokens or passwords. Headers can make use of the reference Secret Key Details, see below, using the syntax ${_datasource.SecretKey}
For example,
- Name:
AuthValue
Authorization
- Expression: ${
_datasource.MyKey}
Tip |
---|
When sending an authorisation header to a PhixFlow API Endpoint, the Name must be Authorization . See Setting up an API Endpoint. |
Secret Key Details
Secret Keys allow sensitive data, such as passwords or security tokens, to be encrypted and stored in the PhixFlow Database. See Secret Key and Local Secret.Image Removed
Image Added
Running HTTP Actions
Individual action nodes can be run in isolation from the rest of the Actionflow, using the Insert excerpt |
---|
| _run_action |
---|
| _run_action |
---|
nopanel | true |
---|
|
option, found under the Insert excerpt |
---|
| _more_options |
---|
| _more_options |
---|
nopanel | true |
---|
|
menu on the HTTP action's Properties. See Running Actions and Actionflows.
HTML Comment |
---|
|
Insert excerpt |
---|
| HTTP Node |
---|
| HTTP Node |
---|
nopanel | true |
---|
|
|
Worked Example
Excerpt |
---|
|
Here is a worked example using the Shop the Retail Data (available from the Learning Centre) and JSON data from the UK government website (https://www.gov.uk/bank-holidays.json). In this example, we are using: - A Shop Shipping screen containing a grid of Orders data, a grid of Order Lines data, an area containing a Date form field and buttons - this screen was created using the Multi-Tile template
- A Shop Shipping Popup screen containing a grid of the bank holiday data - this screen was created using the Tile no Buttons template
Tip |
---|
If you are completing this chapter as part of the Actionflow course and using a training instance, the data and screens have already been pre-loaded into the Actionflow Intermediate Application. For these example, we'll be working on the Search button on the Shop Shipping screen, and the Shop Shipping Popup screen. |
Identify Bank Holiday DatesIn this example, we'll create an Actionflow that retrieves bank holiday dates in the UK from the government website in JSON format and map this onto a screen in a grid.
HTML Comment |
---|
| Select shipment date date field (date picker), then press Ship Date which changes the status of the order and order lines to completed. Area underneath showing upcoming bank holidays |
Table Setup- Create a new
Insert excerpt |
---|
| _tables |
---|
| _tables |
---|
nopanel | true |
---|
| on your to save the bank holiday data to, and ensure it contains the following attributes:- Name:
UID - Type:
String - Length:
50 - Expression:
_NULL
- Name:
Name - Type:
String - Length:
200 - Expression:
_NULL
- Name:
Date - Type:
Date - Leave the Expression field blank
- Name:
Country - Type:
String - Length:
50 - Leave the Expression field blank
HTTP Action SetupOn the Shop Shipping screen, add an Actionflow to the ("GetDates") button Select Click to Connect and choose On Click Drag a action onto the canvas and give it a suitable name - this will be used to retrieve the bank holidays from the government JSON URL Drag the connection point node onto the action Click on the action to open its Properties- HTTP Method: GET
- URL: https://www.gov.uk/bank-holidays.json
- Drag a
Insert excerpt |
---|
| _action_json |
---|
| _action_json |
---|
nopanel | true |
---|
| action onto the canvas and give it a suitable name - this will be used to convert the JSON data into data suitable for our bank holiday table - Connect the out connector from the HTTP node to the JSON node
Map across all attributesattribute, body
Expand |
---|
|
|
JSON Action Setup- Click on the
Insert excerpt |
---|
| _action_json |
---|
| _action_json |
---|
nopanel | true |
---|
| action to open its Properties- Input Expression:
in.body - Path:
$..events Output Attributes:
Code Block |
---|
theme | Emacs |
---|
title | Name: Country, Type: String |
---|
| _result.^.^.division |
Code Block |
---|
theme | Emacs |
---|
title | Name: Date, Type: Date |
---|
| toDate(_result.date, "yyyy-MM-dd") |
Code Block |
---|
theme | Emacs |
---|
title | Name: ID, Type: String |
---|
| toString(_result.date, "yyyyMMdd") + substring(_result.^.^.division, 1,1) |
Code Block |
---|
theme | Emacs |
---|
title | Name: Title, Type: String |
---|
| _result.title |
- Hover over the JSON action and select out
- Create a
Insert excerpt |
---|
| _action_save |
---|
| _action_save |
---|
nopanel | true |
---|
| action- Primary Table:Shop The Bank Holidays table you created earlier
- Map across the JSON attributes to their relevant attributes on the Save action
Expand |
---|
|
|
- Hover over the Save action and choose out
Create an Insert excerpt |
---|
| _action_screen |
---|
| _action_screen |
---|
nopanel | true |
---|
| action to open the Shop Shipping Popup screen Expand |
---|
|
|
Screen Setup- Open the Shop Shipping Popup screen
- Click on
Insert excerpt |
---|
| _attributes |
---|
| _attributes |
---|
nopanel | true |
---|
| in the toolbar, then select the Bank Holidays table you created earlier - In the Available Attributes selector, select all attributes and drag them onto the screen, then choose to display the data as a
Testing- Close all open screens and reopen the Shop Shipping screen
- Click the button to run the Actionflow
- If the Actionflow is working, the Shop Shipping Popup screen should open containing all of the bank holiday data from the government website
Background Filter and Default Sort OrderTidy up your Shop Shipping Popup screen by hiding the UID column on the grid, adding a Default Filter to show only bank holidays in the future, and Default Sort Order to show the most recent bank holidays first.
Expand |
---|
| - Right-click on the grid and choose,
Insert excerpt |
---|
| _view_show_config |
---|
| _view_show_config |
---|
nopanel | true |
---|
|
- In the Data Retrieval Options section of the Properties:
- For Background Filter, select the
Insert excerpt |
---|
| _addIcon |
---|
| _addIcon |
---|
nopanel | true |
---|
| icon to create a new background filter - For Default Sort Order, select the
Insert excerpt |
---|
| _addIcon |
---|
| _addIcon |
---|
nopanel | true |
---|
| icon to create a new sort order
|
|
2.13 JSON Action ConfigurationImage Added