Insert excerpt | ||||||||
---|---|---|---|---|---|---|---|---|
|
What is an API Endpoint?
Excerpt | ||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| ||||||||||||||||||
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
|
Excerpt | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Creating an API EndpointSetupAPI endpoints must be made using the specific option on the
Expand |
The structure of the URL is as follows: https://<<Server Name>>/phixflow/api/1/action/<<Application Name>>/<<Actionflow Name>>/trigger 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. | <<Actionflow Name>> | The name of the actionflow set in Step 1. Note that if your actionflow has a space in the name this must be replaced with | %20. For example "My API" becomes, "My%20API". Insert excerpt | _save | _save | nopanel | true | Input Parameters Insert excerpt | | _actionflow_api_endpoint | _actionflow_api_endpoint | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
name | text | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
nopanel | true | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Insert excerpt | _input | _input | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
nopanel | true | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Insert excerpt | _property_settings | _property_settings | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
nopanel | true | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Insert excerpt | _add_icon | _add_icon | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
nopanel | true | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Insert excerpt | _input | _input | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
nopanel | true | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Note |
Insert excerpt | ||||||||
---|---|---|---|---|---|---|---|---|
|
On the Input Connection Point, additional Input Parameters can be created to facilitate query string parameters being passed into the API via the URL.
- Click on the
nodeInsert excerpt _input _input nopanel true - The
will open on the right and in the Input Parameters section, click theInsert excerpt _property_settings _property_settings nopanel true
icon to create a new attributeInsert excerpt _add_icon _add_icon nopanel true - Enter a Name and Default Value (optional)
The Name set on the
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 HTTP Action Configuration. Insert excerpt _input _input nopanel true
If a parameter is missing then it will be marked as unavailable, unless a Default Value has been configured.
Note |
---|
If a “timeout” parameter is sent via the URL, a corresponding Input Parameter is not required on the API Endpoint. See Timeout below. |
URL & URL Alias
URL and URL Alias can be found on the API Endpoint
Insert excerpt | ||||||
---|---|---|---|---|---|---|
|
Copy the URL and save it locally, to be used later when calling the API
Expand title Url Structure 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
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>> The name of the API.
Note: If the API Name contains a space, this is replaced with %20
.
For example "My API" becomes, "My%20API".- Use URL Alias to modify the URL for the API
- When set, instead of the URL being constructed using the API Endpoint name and application name, it will use the alias instead
URL Alias Example
If the API URL is, https://server.phixflow.com/phixflow/api/1/action/My%20App/My%20API%20Endpoint/trigger and a URL Alias of CompanyData is set, then the API URL will change to, https://server.phixflow.com/phixflow/api/2/CompanyData
API Mode
API Mode can be found on the API Endpoint
Insert excerpt | ||||||
---|---|---|---|---|---|---|
|
Choose an API Mode:
- Wait for result (Synchronous) (Default): The API waits for the results or the timeout to occur
- Note: If the timeout occurs the command is aborted
- Poll for result (Asynchronous): The API is called and a response is returned immediately including the process ID
- Subsequent API calls can be made using the process ID to fetch the status of the action
- The asynchronous mode can be thought of as “fire and forget”
Authorisation
Allow Anonymous Connections can be found on the API Endpoint
Insert excerpt | ||||||
---|---|---|---|---|---|---|
|
If Allow Anonymous Connections is enabled:
Excerpt | ||
---|---|---|
| ||
This allows anyone with the URL for the API to call it. The audit trail records the system as running performing the API call. |
Note: Adding authorisation is covered on API Authentication and Secret Keys.
Timeout
Timeout can be found on the API Endpoint
Insert excerpt | ||||||
---|---|---|---|---|---|---|
|
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
API Status Check (Poll for Result)
- If calling a PhixFlow Asynchronous API only, a result will be immediately returned which includes a Process ID for that run
- The Process ID is returned on the path:
$.processId
- This can be accessed in an Output attribute using,
_result.value
- The Process ID can be used to call the following URL which will return the current state of the run:
- https://<<Server Name>>/phixflow/api/1/action/<<Application Name>>/<<Actionflow Name>>/poll/<<processID>>
Calling a PhixFlow API
HTTP Method
This is set on the
Insert excerpt | ||||||
---|---|---|---|---|---|---|
|
- To call a PhixFlow API use the HTTP Method GET or POST:
- GET simply calls the API with data passed in the body of the request
- POST calls the URL and sends data in the body of the request. The body data is passed into the body attribute of the API as an Input Connection point
Returned Data JSON Path
If your API has been configured to return data the path will be in the format:
$.data.<<Output Name>>
Where <<Output Name>> is the Output connection point.
Server Console Responses
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
Insert excerpt | ||||||
---|---|---|---|---|---|---|
|
If you are making the call using PhixFlow the Responses can be access as follows:
- Click the Actionflow entry
- In the Messages section which is opened below, double-click the lines that begin Response
- Click the Message Details tab to see the response
API Endpoint Results
To see the results of the API Endpoint processing in the
Insert excerpt | ||||||
---|---|---|---|---|---|---|
|
- Click the Actionflow entry for the API Endpoint
- In the Messages section which is opened below, double-click any of the Messages to see more details
- If you are using a debug() statement these will appear here
Failures
An API Endpoint will fail if the logic in the Actionflow fails or if the error() 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.
Error Codes
200
- Occurs if the output of an API Endpoint is not connected
Occurs if the output is connected and a record is returned
400
Occurs if the output is connected but no record is returned
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
Tip |
---|
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. |
Excerpt | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Example 1: Passing Out DataIn this example, we'll configure an API Endpoint that passes out Company ID, Company Name and Industry data from our Companies data. Create API EndpointIn this example, we'll set up an API Endpoint to pass out company data.
Construct JSON
Configure the Output
Example 2: Passing in ParametersIn 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. API End Point Setup
Call API Actionflow Setup
Testing
|