General information
The setting of the outgoing HTTP request is held in the Request tab. We set up all the required parameters. Headers and alternative parameters are added as the separate fields with the additional keys (value and type).
Request method
Select the method from the list. Available methods:
GET
POST
PUT
MERGE
PATCH
DELETE
Request URL
Enter the endpoint address to send the HTTP request. You can enter both static text and dynamic variables (entity fields). For example, you can transfer certain IDs between slashes in the url / /
If you use a POST request, but want to transfer some GET parameters, you can add it in the URL. For example:
Please note, URL must be valid and starts with https: // or http: //
All GET parameters in the URL (after the ?symbol) will be urlEncoded automatically.
Content-type
Specify the format of the request to send. Available options:
JSON
XML
urlEncoded
The required Content-type header will be automatically substituted in the request.
Authorization
Select one of the created app authorizations. Authorization data will be automatically substituted in the request. Optional parameter.
Headers
If you need to send the additional headers, add fields in this tab. Each field on the left indicates a key, on the right - the value of this header. For example, when you need to send the following header:
curl -H "Action: create"
Click the Add field button, fill in the left field with the Actionvalue, and the right one with create value.
A dynamic parameter (entity fields) is also available in the right field. It will be filled in the automation.
Parameters
Parameter is the body of the request. Each field that will be added here will form the request body in the selected format and method. If the GET method is selected, then all fields created on this tab will be automatically added to the URL as GET parameters.
As well as in the header tab, add the fields and indicate variable key mapping on the left, the value in the middle, and the type of the variable on the right.
It is important to indicate the mapping correctly. Let's take JSON as an example, if you need to fill in the name variable and JSON looks like this:
{ "name":"John"}
Specify key name .
If the required variable is in the object, the path to the object is indicated through a dot.
JSON example:
{ "contact":{ "name":"John" }}
In order to fill in the variable name, you need to specify the key mapping in the left field like this: contact.name.
If the variable is in an object array and you need to fill a specific object, then the mapping is indicated through a dot with a position in array (counting starts from zero). JSON example:
{ "contacts":[ { "name":"John" }, { "name":"Smith" } ]}
If you need to fill in name in the first object, the mapping is specified like contacts.0.name, second object - contacts.1.name
This scenario is possible with a predictable number of objects in the array. In other cases we create a string section in the entity fields and select the “Array of objects” field type. Thus, the objects will be created as many as they fit the string section.
Example:
Variable types
Select the type of the variable in the right field of the parameters tab. Available options:
String – String ””
Int - Integer
Decimal - Fractional number
Boolean - The field has a list with the values true/false
dateTime - Date and time type needs an additional format conversion. Click the gear button to specify date format and time zone, as well as variable format (int or string).
Phone - Another internal type. Click the gear button to specify format and final type of the variable (int or string). Select the mask of the phone number (how it will be displayed) in the format settings. This scenario helps to send the phone number in strict API format (e.g., + +{{countryCode}}########## . Select this mask and Albato will automatically convert such phone numbers as +7(968)111-22-33 into correct API format.
ObjectArray - Array of objects, this type is used with the string section (created in the entity fields). Specify the way to the array in the key and select the string section in the value.
All types (except ObjectArray) can also have an additional type with + array at the end. This type means the data is transferred in an array of elements (ed. StringArray). Namely, when you need to fill in JSON in this form:
{ "tags":[ "tag", "tag2", "tag3" ]}
and select the StringArray type. Use this type creating an action with the same field type to collect values in an array of strings separated by commas.
Also, selecting this additional type, click the gear button to specify a space character between the set of elements (default symbol ,).
Date and Time
Select the required type of variable to send date and time in the request. There are three additional fields available in the settings (click gear button):
Type – the final type of variable to transfer. Int (with auto conversion into unixtime) and string are available.
Format – Fill in the date format according to the PHP documentation. The date in this field will be auto converted into the selected format (dd.mm.yyyy hh:mm:ss as well as Y-m-d H:i:s ). Fill in the format following the PHP documentation. If the format is Y/m/d+H:i:s so the date 21.03.2021 19:00:00 will be converted into 2021/03/21+19:00:00and sent to HTTP request.
Time zone – Select the time zone of the date. Any date and time will be converted to the selected time zone.
Objects Array
The ObjectArray variable type is a sub-entity in the request tab.
In this type the field is converted into a separate array. You cannot undo the action, only delete.
Enter the mapping to the array in the left field after the selection. Select the request entity in the string section of the right field. You can add selected string section fields and static values.
For created fields in the array, key mapping is written without specifying the path to the array. In this case, JSON looks like this:
{ "items":[ { "name":"Item 1", "quantity":1 }, { "name":"Item 2", "quantity":3 } ]}
Field with the ObjectArray type has a mapping key – items. Thus, an array has two fields with the keys: name and quantity. The values of such fields are filled with string section fields entity selected in the parent field.