HTTP API
Last updated
Last updated
© 2024 UI Bakery
If your API is hosted behind a Firewall, add the following IP address to the Firewall whitelist:
To interact with the data via API, you can use an HTTP Request action step and configure HTTP parameters based applicable to your API. UI Bakery supports all HTTP methods, Headers, Body, and Query Parameters. You can set up your own or select a default HTTP data source.
If you are using the default HTTP data source, you can specify the URL of your request directly in the action. This is the main required parameter for the HTTP action:
You can also specify additional parameters that can be required depending on the API:
Method - http request method - GET, POST, PUT, etc;
URL - url or path of the API endpoint;
Base URL - in case a data source is connected to the action, base API url can be provided so that you don't need to specify a whole URL for each action and can change it on the data source level once for all actions;
Headers - http request headers - string key value pairs;
Body - for methods such as POST/PUT, an http body can be specified as a JSON object or as a plain text;
Query params - url params added to the request url;
Transform result - pass a JS function to transform execution result or fix an error. {{data}}
, {{error}}
, {{res}}
variables represents the result of the request.
If the HTTP data source server sets the cookies, these cookies will be passed for the subsequent requests to the server as well, but will not be visible in the {{res}}.
You can find them in the network tab of the Chrome dev tool for the request that is sent to execute the HTTP step.
Please note that to make the cookies work, you have to configure your HTTP API as a data source first.
For example, you can pass a JSON object in a Body of your request by adding a Content-Type
header to it:
In case your HTTP Requests share similar settings like a base URL or auth headers, or your API requires authentication, you can configure your HTTP API as a data source.
Navigate Data sources - Connect - choose HTTP API from the list.
Specify your Base URL and additional parameters, when required. If you need to set up authentication, follow this guide: API authentication.
Click Connect Datasource to save the configuration.
Please note that the settings defined on a data source level are sent from the backend proxy and are not exposed to the frontend user.
Input - no specific input is required. {{data}}
and {{params}}
variables can be used to access a previous step result or an incoming action's parameters.
Output - {{data}}
- API request result, {{error}}
- API request error, {{res}}
- full HTTP response object.
UI Bakery allows you to import API requests via cURL
Add an HTTP request action step, click Import CURL, and paste your cURL command into the field. The system will fill in the configuration automatically. Then Run Action and check the Result tab.
Load and send data from your or 3rd party APIs;
Integrate with 3rd party services such as Zapier, Integromate (Make), etc.
1. Create an action and set an API URL:
2. Enable Transform result and add a JavaScript function to modify the result. Learn more about the data mapping here.
3. Run action and check the result:
Let's take look at how to send a form to make a POST API request.
1. Add a form component to your page. Note, if you add a form while your load data action is selected in the action panel, the form will inherit the response structure, so that you don't need to configure it manually.
2. Create a new HTTP action, change its method to POST, open up Body tab and change it format to JS Object. Then reference your newly added form as {{ui.myForm.value}}
:
3. Assign the action to the form's On Submit trigger - now whenever you click the Submit button, action will be executed and POST API request sent to the API:
4. Fill in the form, click Submit and check the result:
Sometimes your API may return an error, e.g. if any required field is missing or is not correct. To check what data has been sent to the server, you can open the Payload section of the result panel and investigate header, url, body and other sent parameters: