- Created by Zoe Baldwin , last modified on Oct 22, 2024
You are viewing an old version of this content. View the current version.
Compare with Current View Version History
« Previous Version 54 Next »
What is an API Endpoint?
API endpoints must be made using the specific option on the
On the Input Connection Point, additional Input Parameters can be created to facilitate query string parameters being passed into the API via the URL. The Name set on the If a parameter is missing then it will be marked as unavailable, unless a Default Value has been configured. If a “timeout” parameter is sent via the URL, a corresponding Input Parameter is not required on the API Endpoint. See Timeout below. URL and URL Alias can be found on the API Endpoint Copy the URL and save it locally, to be used later when calling the API The default structure of the URL (i.e. with no URL Alias set) is as follows: https://<<Server Name>>/phixflow/api/1/action/<<Application Name>>/<<Actionflow Name>>/trigger The name of the API. Note: If the API Name contains a space, this is replaced with %20 If the API URL is, https://server.phixflow.com/phixflow/api/1/action/My%20App/My%20API%20Endpoint/trigger and a URL Alias of Company Data is set, then the API URL will change to, https://server.phixflow.com/phixflow/api/2/Company%20Data API Mode can be found on the API Endpoint Choose an API Mode: Allow Anonymous Connections can be found on the API Endpoint If Allow Anonymous Connections is enabled: Note: Adding authorisation is covered on /wiki/spaces/HELP12/pages/9615607547. Timeout can be found on the API Endpoint Set a Timeout (optional): Specify a maximum time in milliseconds that the API will wait for before the command is aborted When a Timeout value is set, it overrides the default timeout, which is 60 seconds where API Mode is Synchronous and 500 milliseconds where API Mode is Asynchronous However, if a timeout parameter has been provided in the URL calling this API, that will override both this Timeout value and the default value This is set on the See /wiki/spaces/HELP12/pages/9615606000. If your API has been configured to return data the path will be in the format: Where <<Output Name>> is the Output connection point. The item calling the API endpoint will receive the Response from the API endpoint stating whether it has run successfully (Success) or not (Fail). Responses can be customised to return specific messages. The response recorded in the If you are making the call using PhixFlow the Responses can be access as follows: To see the results of the API Endpoint processing in the An API Endpoint will fail if the logic in the Actionflow fails or if the /wiki/spaces/HELP12/pages/9615607495() function is used to force a failure. If records are passed to the API Endpoint individually a failure will only impact the specific record being processed. Occurs if the output is connected and a record is returned Occurs if the output is connected but no record is returned
API endpoints can be setup to enable external systems to make calls to PhixFlow. API endpoints can be seen in the Repository for your application under API Endpoints and on the
Actionflow homepage with the
icon.
Creating an API Endpoint
Actionflow homepage to ensure a URL is generated and a set of predefined input parameters are configured on the incoming connection point.
API Endpoint on the
Actionflow homepage using the
option
Repository, right-click on the API Endpoint name and choose
Display
Properties will open on the right - for the full Properties list, see API Endpoint Properties
Input Parameters
API Endpoints have fixed parameters set on the input node (body, headers, contentType and url), and the output node (body, headers, contentType and statusCode) which can be mapped to.
input node
Properties will open on the right and in the Input Parameters section, click the
icon to create a new attribute
input must match the parameter name in the URL, e.g. if an Input Parameter, "field" is created, and the request URL is https://server/phixflow/api/1/action/App/Api/trigger?field=abc then the value "abc" will be used as a parameter. When calling APIs using query string parameters in the URL, care should be taken to ensure that the values are appropriately URL encoded to prevent unexpected behaviour. See /wiki/spaces/HELP12/pages/9615606000.
URL & URL Alias
Properties.
Parameter Description <<Server Name>> URL of the server e.g. app.phixflow.com phixflow the name of the instance, typically this is phixflow
<<Application Name>> The name of the application where the Actionflow resides. <<API Name>> .
For example "My API" becomes, "My%20API". URL Alias Example
API Mode
Properties.
Authorisation
Properties.
Timeout
Properties.
API Status Check (Poll for Result)
$.processId
_result.value
Calling a PhixFlow API
HTTP Method
HTTP action on the Actionflow calling the API.
Returned Data JSON Path
$.data.<<Output Name>>
Server Console Responses
System Console:
API Endpoint Results
System Console:
Failures
Error Codes
200
400
Worked Example
Here's a worked example using the Company Data (available from the Learning Centre).
In this example, we are using:Â Â
- A Company Call API screen containing a fixed drop down list of industries, a string fields for the API Status and a multi-line string field for the Results - this screen was created using the Tile with Buttons template
If you are completing this chapter as part of the Actionflow course and using a training instance, the screens have already been pre-loaded into the Actionflow Advanced Application. For this example, we'll be working on the Company Call API screen.
In this example, we'll configure an API Endpoint that passes out Company ID, Company Name and Industry data from our Companies data. In this example, we'll set up an API Endpoint to pass out company data. From the Expression: Map the JSON attribute from the Calculate action to the body attribute In this example, we'll retrieve data from our Companies API and pass in an industry parameter (e.g. "Telecoms") to filter the results to just companies in that industry. Body: Log Traffic: Create a Name: Path: Create 2 Output Attributes on the JSON action On the HTTP action, Call API, the option to Log Traffic was enabled allowing the API response to be seen in the Example 1: Passing Out Data
Create API Endpoint
API Endpoint on the
Actionflow homepage using the
option
API Company Data
Properties open on the right
Apply your changes
Construct JSON
Calculate action
GetDataAndConstructJSON
Calculate action, create a lookup to the Companies data
getCo
CompanyData
Companies
JSON
Structured Data
toJson(getCo)
Apply and Close
Configure the Output
output connection node onto the Calculate node
Example 2: Passing in Parameters
API End Point Setup
JSON action to receive the parameter
GetIndustry
in.body
$
IndustryReceived
String
_result.Industry
JSON action between the
input and
Calculate nodes
input and
JSON nodes, map across body, contentType, headers and url
View action, add a filter:
ByIndustry
Call API Actionflow Setup
HTTP action:
Call API
POST
[{
"Industry": "${in.Industry}"
}]
JSON action
ReturnedCompanies
in.body
$.getCo
CoName
String
_result.1.CompanyName
CompanyID
Integer
_result
.1.
CompanyID output connection point back to the screen
Testing
System Console Response
System Console.
System Console via the
Administration option
On this page
- No labels