HTTP Action Configuration
What is a HTTP Action?
HTTP actions perform HTTP(S) requests to external APIs and return the response.
Creating HTTP Actions
- Click and drag the HTTP icon from the toolbar onto the canvas
- Enter a name for the HTTP action, then select Create Action
- In the HTTP action Properties on the right, populate the following details:
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, DELETE, OPTIONS, PUT, PATCH. | Get |
URL Template | A template that computes the URL of the request. 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 | //JSON Example { "Industry" : "${in.Industry}" } |
Error Expression | Optional. A JEP expression to determine if the response is an error and if so, send on the Error 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 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. | |
Maximum HTTP Log Length | Available if Log Traffic is toggled on . Restricts the size of the log traffic. | 1000 |
Use Raw URL | Toggle on to send the URL Template value in exactly the format it is provided to the HTTP Node. If toggled off PhixFlow will transpose values to form a valid URL, such as replacing spaces with %20. | |
HTTP Configuration | See HTTP Configuration |
4. Apply and Close all settings
5. Hover over the HTTP 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 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:
body: The content returned by a successful request, for example, JSON content
- contentType: The type of response provided by the target HTTP request, for example,
application/json; charset=utf-8
- status: The returned status code, for example,
200
- statusMessage: The returned status message, for example,
OK
- 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 return200
- transmissionError: Returns true if the request failed, e.g. timed out
Parameters
Parameters 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
HTTP Action
API Endpoint Input Parameters
If a “timeout” parameter is required, this can be set on the HTTP action but is not needed as an Input Parameter on the API Endpoint. This is because it is a reserved value. See API Endpoint Properties and Setting up an API Endpoint.
Headers
Headers are typically used to specify information for the request, such as character sets, session tokens or passwords. Headers can reference Secret Key Details, see below, using the syntax ${_datasource.SecretKey}
For example,
- Name:
Authorization
- Expression: ${
_datasource.MyKey}
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.
Running HTTP Actions
Individual HTTP action nodes can be run in isolation from the rest of the Actionflow, using the Run Action option, found under the More Options menu on the HTTP action's Properties. See Running Actions and Actionflows.
Worked Example
Here is a worked example using 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: 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. In 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. On the Shop Shipping screen, add an Actionflow to the ("GetDates") button Select Click to Connect and choose On Click Drag a HTTP 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 input connection point node onto the HTTP action Click on the HTTP action to open its Properties Map across attribute, body Output Attributes: Create an Open Screen action to open the Shop Shipping Popup screen Tidy 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.Identify Bank Holiday Dates
Table Setup
UID
String
50
_NULL
Name
String
200
_NULL
Date
Date
Country
String
50
HTTP Action Setup
JSON Action Setup
in.body
$..events
_result.^.^.division
toDate(_result.date, "yyyy-MM-dd")
toString(_result.date, "yyyyMMdd") + substring(_result.^.^.division, 1,1)
_result.title
Screen Setup
Testing
Background Filter and Default Sort Order