Call Web Services from the process workflow
In Flokzu you have the possibility to call Web Services REST to carry out different operations such as enter data into a form, send information to an external server or even assigning a task.
The first thing you should do is to place a Service Task at any stage of your workflow where you want to make a service call to a Web Service.
Finally, you must configure the Web Service you want to invoke with the following steps:
Enter the URL and the type of service (method) you wish to invoke.
Configure the input data to be sent to the Web Service
Configure the output data that is received from the Web Service and can be loaded into form fields in Flokzu.
Configure the HTTP Headers (optional), for security reasons, for example.
Finally you can select the authentication used by your service in the Authentications tab.
Type or paste the URL of the service (endpoint) you want to invoke and select the method from the list on the right.
In case it is necessary to reference the content of a form field in the URL of the webservice, it must be done using mustaches {{Field Name}}.
The supported methods are:
GET
PUT
POST
DELETE
The queryParam must be explicitly included in the URL, except in the case of GET method that will take them from the input parameters (see point 2).
For each input parameter Flokzu allows you to insert the content of your form fields or send literal values. Click on the pencil icon to toggle between the two options.
The parameters will be automatically translated in the body of the call, except when using the GET method where they will be sent as queryParam.
Let's see some examples:
With GET method the input parameters are sent in the URL. A configuration like the following
will invoke the following URL:
https://api.myapp.com/v1/service?param1=value_1¶m2=value_2
With PUT, POST and DELETE methods, a configuration like the following one
will send the following JSON in the request:
It is possible to customize the service call by writing the body directly or by indicating that the parameters should be sent as url-encoded
The raw option allows you to write the input JSON directly. In addition, using mustaches you can insert the content of a form field directly into the body.
To enable mustaches you must type a space followed by a double curly brace: " {{"
If your service requires sending data as url-encoded, select the x-www-form-urlencoded option in the Input Parameters tab. Then you can add the parameter - value pair
Form-data refers to a form of communication between web services, where data is sent as key/value pairs. While it is useful for sending any type of data (text, numbers, boolean values), it is also the only mechanism that supports "multipart/form-data" encoding, which is necessary to send attachments.
If you select this option and do not add a Content-Type header, Flokzu will automatically add this multipart/form-data header.
Flokzu supports two types of response in the services that you will have to choose in the Output Data tab:
RAW: The REST service response must be a valid JSON. You can check the JSON using the following web http://jsonviewer.stack.hu/
BINARY: A file that you can attach in the Attachments Tab or in a form field.
After choosing this option you should indicate the parameter you want to access, and in the right column the form field where you want to insert that value.
Let's assume that this is the output JSON:
You can get the different values by navigating between the properties using a dot (.) or by indicating the index of the arrays in square brackets.
Next we will see how to configure the output parameters to access some of the properties.
If the web service you are invoking returns a file in its response, you will be able to attach it to your process instance. After selecting the Binary option, you must choose from the list the field where the attachment will be saved.
Enter the HTTP Headers (optional), for security reasons, for example.
Finally, you can select the authentication used by your service on the Authentications tab
To send information from a Flokzu form towards an external server.
To receive information from an external server and enter it on a Flokzu form.
To add new records on a Flokzu internal database (add record).
To get records from a Flokzu internal database (get record).
To list records from a Flokzu internal database (list record).
To update records from a Flokzu internal database (update record).
To start a new process in Flokzu when a Service Task is reached at any stage of a process workflow.
To get information from a process instance.
To update information from a process instance.
If you want to integrate with other apps, and these doesn't support Web Services, you can do it as well. Simply place a Service Task in the workflow, then select 'Zapier' and follow the steps to integrate Flokzu and Zapier. Once the integration is set up, you'll be able to connect Flokzu with more than 1,000 apps (Facebook, Google Drive, Gmail, SalesForce, etc).
How can I call a Web Service from the process workflow?
The first thing you should do is to place a Service Task at any stage of your workflow where you want to make a service call to a Web Service.
Finally, you must configure the Web Service you want to invoke with the following steps:
Enter the URL and the type of service (method) you wish to invoke.
Configure the input data to be sent to the Web Service
Configure the output data that is received from the Web Service and can be loaded into form fields in Flokzu.
Configure the HTTP Headers (optional), for security reasons, for example.
Finally you can select the authentication used by your service in the Authentications tab.
1. Configure URL and method
Type or paste the URL of the service (endpoint) you want to invoke and select the method from the list on the right.
In case it is necessary to reference the content of a form field in the URL of the webservice, it must be done using mustaches {{Field Name}}.
The supported methods are:
GET
PUT
POST
DELETE
The queryParam must be explicitly included in the URL, except in the case of GET method that will take them from the input parameters (see point 2).
2. Configure input data (Body of the call)
For each input parameter Flokzu allows you to insert the content of your form fields or send literal values. Click on the pencil icon to toggle between the two options.
The parameters will be automatically translated in the body of the call, except when using the GET method where they will be sent as queryParam.
Let's see some examples:
With GET method the input parameters are sent in the URL. A configuration like the following
will invoke the following URL:
https://api.myapp.com/v1/service?param1=value_1¶m2=value_2
With PUT, POST and DELETE methods, a configuration like the following one
will send the following JSON in the request:
{
"param1": "value_1",
"param2": "value_2"
}
Customization of the Body of the call
It is possible to customize the service call by writing the body directly or by indicating that the parameters should be sent as url-encoded
RAW
The raw option allows you to write the input JSON directly. In addition, using mustaches you can insert the content of a form field directly into the body.
To enable mustaches you must type a space followed by a double curly brace: " {{"
URL-ENCODED
If your service requires sending data as url-encoded, select the x-www-form-urlencoded option in the Input Parameters tab. Then you can add the parameter - value pair
FORM-DATA
Form-data refers to a form of communication between web services, where data is sent as key/value pairs. While it is useful for sending any type of data (text, numbers, boolean values), it is also the only mechanism that supports "multipart/form-data" encoding, which is necessary to send attachments.
If you select this option and do not add a Content-Type header, Flokzu will automatically add this multipart/form-data header.
3. Configure output data (Response body)
Flokzu supports two types of response in the services that you will have to choose in the Output Data tab:
RAW: The REST service response must be a valid JSON. You can check the JSON using the following web http://jsonviewer.stack.hu/
BINARY: A file that you can attach in the Attachments Tab or in a form field.
RAW
After choosing this option you should indicate the parameter you want to access, and in the right column the form field where you want to insert that value.
Let's assume that this is the output JSON:
{
"name": "JSON example.",
"description": "This is a JSON example with multiple levels and data within an array.",
"author": {
"name": "John Doe",
"age": 35,
"active": true
},
"values": [10, 20, 30, 30, 40],
"users": [
{
"id": 1,
"name": "Alice",
"email": "alice@example.com",
"active": true,
"roles": [ "admin", "user"]
},
{
"id": 2,
"name": "Bob",
"email": "bob@example.com",
"active": false,
"roles": [ "user"]
}
]
}
You can get the different values by navigating between the properties using a dot (.) or by indicating the index of the arrays in square brackets.
Next we will see how to configure the output parameters to access some of the properties.
Use case | Configuration | Returned value |
---|---|---|
Property at the first level | name | JSON example |
Property at the second level | author.active | true |
Value within an array | values[2] | 30 |
Navigation within arrays level | users[0].roles[0] | admin |
Navigation within arrays and properties | users[0].name | Alice |
BINARY
If the web service you are invoking returns a file in its response, you will be able to attach it to your process instance. After selecting the Binary option, you must choose from the list the field where the attachment will be saved.
4. Configure HTTP Headers
Enter the HTTP Headers (optional), for security reasons, for example.
5. Configure Authentications
Finally, you can select the authentication used by your service on the Authentications tab
Examples of typical Web Services
To send information from a Flokzu form towards an external server.
To receive information from an external server and enter it on a Flokzu form.
To add new records on a Flokzu internal database (add record).
To get records from a Flokzu internal database (get record).
To list records from a Flokzu internal database (list record).
To update records from a Flokzu internal database (update record).
To start a new process in Flokzu when a Service Task is reached at any stage of a process workflow.
To get information from a process instance.
To update information from a process instance.
What if I want to integrate with an app that doesn't support Web Services?
If you want to integrate with other apps, and these doesn't support Web Services, you can do it as well. Simply place a Service Task in the workflow, then select 'Zapier' and follow the steps to integrate Flokzu and Zapier. Once the integration is set up, you'll be able to connect Flokzu with more than 1,000 apps (Facebook, Google Drive, Gmail, SalesForce, etc).
Updated on: 21/06/2024
Thank you!