Blocworx Documentation

Blocworx Gateway

The Blocworx Gateway Field is designed to send requests to API and then use the response in the bloc. This is useful for gathering information to fill fields in the bloc.
The default behavior is when the Blocworx Gateway field is triggered, a POST request of multipart/form-data will be sent to the API.

Initial Field Parameters

Gateway URL
This is the URL of the API.
Send your current Auth Token with the request
If this field is selected the authenticated user's token will be sent in the request.
Select GET or POST
This option is to change the request action.
Choose when trigger the gateway
This option is to choose when to trigger the request. The current options are when submitting the form, editing a field, or manually using a created button.
Choose actions with the response
The current options are to populate the fields in the form using the data of the API response and to trigger rules on populated fields.
Field to Trigger the request
This option is to choose which fields in the bloc will trigger the request to the API.
Add Header
This option is to enable the user to include any necessary header with the request. It is possible to choose between a set of pre-defined options and type the desired value.
Body Request
This allows the user to specify a Body to send custom information with the Request

An example of how to build the gateway API to translate texts.

In the gateway URL, write the endpoint of the API. e.g. https://microsoft-translator-text
Example of gateway URL
Choose if the action is a post or a get
Example of request action
Choose when the gateway is triggered, in this example, we are using a button to do it. It's also possible to choose the name and color of the button.
Example how to trigger the gateway API
Add headers that are required to call the API properly. e.g. content-type: application/JSON.
Example of Header
You may add as many headers are necessary to call the API properly.
Finally, add the request body that is going to be sent using the gateway API.
e.g. [{text: [BW]Text[/BW]}].
Example of the Request's Body
In the request body field, the user should use the pattern [BW]field_slug[/BW] that will be changed to the value in the chosen field before calling the API.
It's possible to click in the desired field that shows when you click in "Click to view fields to add" and the pattern will be automatically added to the request's body.