In this article, you will learn how to use Remote Request feature of Piotnet for sending data collected by your form to an URL endpoint – a remote server.
Tutorials
1. What is the Remote Request
Remote Request is sending requests to a remote server by HTTP protocol request methods. There are many HTTP Methods: GET, POST, PUT, PATCH, and DELETE.
To deeply understand HTTP Methods, you need to cover the knowledge about Client-server architecture, and API.
Anatomy of an HTTP Request
An HTTP Request must have the following: an HTTP method (like GET or POST), a host URL, and an endpoint path.
A request can also optionally have: body, headers, query strings, and HTTP version.
HTTP Methods
- POST: Use to create a new resource
- GET: Use to read or retrieve a resource
- PUT: Use to modify a resource
- PATCH: Use to modify part of a resource
- DELETE: Use to delete a resource
2. Remote Request feature in PAFE
In PAFE, we provide Remote Request feature as an Action After Submit. By the action, you can select which data to collect from your form and send it to a remote server.
Edit the Submit Button > Select Action After Submit: Remote Request
In the Remote Request Control section, set up your HTTP Request:
- URL: enter your endpoint URL
- Request Arguments: define request Method, request timeout, redirection, HTTP version, and blocking.
- Header Arguments: enter content-type, x-powered-by, accept, API-key.
- Body Arguments: enter body parameters that you want to collect from the form and send them to the endpoint URL. The Parameters are shortcodes of the fields.
“Add Item” to add one or many argument parameters.
Now your Remote request form is ready. If the user fulfills and submit the form, data will be collected and sent to the endpoint.
3. Remote Request Example
In this example, we collect email from a simple form and send to Sendinblue to create a new contact by Remote Request POST method.
Sendinblue is a CRM which manages client contacts. We also integrated Sendinblue in Piotnet: Sendinblue Integration.
Requirement from Sendinblue
This is the official document of Sendiblue about how to Create a contact by POST Request.
According to the document, besides email, some other mandatory parameters are: method, accept, content-type, and api-key.
We need to register a Sendinblue account to generate an api-key.
Setup Remote Request action
Edit the Submit Button, open Remote Request section, and enter argument parameters:
URL: https://api.sendinblue.com/v3/contacts
Request Arguments: method = POST
Header Arguments:
Accept = application/json;
Content-type = application/json;
api-key = the api-key generated by your Sendinblue account
Body Arguments: email = email-field-shortcode
At this point, we already completed the setup. Let’s see how the Remote Request Form works:
> Enter the contact email address on front-end
> Click on Submit Button
> Check the Contacts in Sendinblue
As you can see, the contact was added into Sendinblue.
4. Conclusion
Remote Request in an advanced feature which requires coding knowledge. Just consider to use the feature in case you clearly understand HTTP protocol, API, Client-server Architecture.