Skip to main content

postFormsData

Creating an object of form data saving information.

Description

This method Returns a created FormDataEntity object. If you want to change the language, just pass it with the second argument

Methods with a post request accept as the request body an object with the form data field, which corresponds to the type of information being sent. The following are examples of form data objects for different data types.

FormData.postFormsData(

body, langCode

);

Parameters schema

Schema (body)

body(required): object
Request body
example:

{
"formIdentifier": "form",
"formData": [
{
"marker": "name",
"type": "string",
"value": "Jack"
}
]
}

langCode: string
Language code. Default: "en_US"
example: "en_US"

body.formIdentifier: string
The identifier of the form
example: "contact-form"

body.formData: string
**
example:

[
{
"marker": "name",
"type": "string",
"value": "Jack"
}
]

body.formData.marker: string
Form attribute marker
example: "name"

body.formData.type: string
Form attribute type
example: "string"

body.formData.value: string
Form attribute value
example: "Jack"

Examples

Minimal example

const body = {
"formIdentifier": "contact_us",
"formData": [
{
"marker": "last_name",
"type": "string"
"value": "Andrey"
}
]
};

const response = await FormData.postFormsData(body);

Example with a simple type attribute "string", "number", "float"

const body = {
"marker": "last_name",
"type": "string",
"value": "Username"
};

const response = await FormData.postFormsData(body);

Example with a simple type attribute "date", "dateTime", "time"

const body = {
"marker": "birthday",
"type": "date",
"value": {
"fullDate": "2024-05-07T21:02:00.000Z",
"formattedValue": "08-05-2024 00:02",
"formatString": "DD-MM-YYYY HH:mm"
}
};

const response = await FormData.postFormsData(body);

Example with a simple type attribute "text"

const body = {
"marker": "about",
"type": "text",
"value": {
"htmlValue": "<p>Hello world</p>",
"plainValue": "",
"params": {
"isEditorDisabled": false,
"isImageCompressed": true
}
}
};

const response = await FormData.postFormsData(body);

Example with a simple type attribute "textWithHeader"

const body = {
"marker": "about",
"type": "textWithHeader",
"value": {
"header": "Headline",
"htmlValue": "<p>Hello World</p>",
"plainValue": "",
"params": {
"isEditorDisabled": false,
"isImageCompressed": true
}
}
};

const response = await FormData.postFormsData(body);

Example with a simple type attribute "image" or "groupOfImages"

const body = {
"marker": "avatar",
"type": "image",
"value": [
{
"filename": "files/project/page/10/image/Screenshot-from-2024-05-02-15-23-14.png",
"downloadLink": "http://my-site.com/cloud-static/files/project/page/10/image/Screenshot-from-2024-05-02-15-23-14.png",
"size": 392585,
"previewLink": "",
"params": {
"isImageCompressed": true
}
}
]
};

const response = await FormData.postFormsData(body);

Example with a simple type attribute "files"

const body = {
"marker": "picture",
"type": "file",
"value": [
{
"filename": "files/project/page/10/image/Screenshot-from-2024-05-02-15-23-14.png",
"downloadLink": "http://my-site.com/cloud-static/files/project/page/10/image/Screenshot-from-2024-05-02-15-23-14.png",
"size": 392585
}
]
};

const response = await FormData.postFormsData(body);

Example with a simple type attribute "radioButton" or "list"

const body = {
"marker": "selector",
"type": "list",
"value": [
{
"title": "red",
"value": "1",
"extended": {
"value": "red",
"type": "string"
}
}
]
};

const response = await FormData.postFormsData(body);

Example with attribute type "entity" (nested list)

const body = {
"formIdentifier": "entity_form",
"formData": {
"en_US": [
{
"marker": "entity-marker",
"type": "entity",
"value": [25, 32, 24]
}
]
}
};

const response = await FormData.postFormsData(body);

Value - numerical identifiers for pages and string identifiers for products. Identifiers for products should include the prefix 'p-', for example, 'p-1-', 'p-2-', etc. p-[parentId]-[productId]


Example with attribute type "timeInterval"

const body = {
"formIdentifier": "reg",
"formData": {
"en_US": [
{
"marker": "interval",
"type": "timeInterval",
"value": [
[
"2025-02-11T16:00:00:000Z",
"2025-02-13T16:00:00:000Z",
]
]
}
]
}
};

const response = await FormData.postFormsData(body);

value — array of interval arrays in ISO 8601 format. for example 2025-02-11T16:00:00:000Z

2025 — year; 02 — month; 11 — day of the month; T — separator between date and time; 16:00:00 — time in hours:minutes:seconds format; 000Z — milliseconds and time zone indication. Z means that the time is specified in UTC format.


Example return:

{
"formData": {
"formIdentifier": "test-form",
"time": "2025-07-21T09:40:06.587Z",
"formData": [
{
"marker": "name",
"type": "string",
"value": "Test"
}
],
"id": 286
},
"actionMessage": ""
}

Response schema

Schema: IFormDataEntity

formIdentifier: string
The identifier of the page.
example: "contact_form"

time: Date | string
The identifier of the form.
example:

"2023-10-01T12:00:00Z"

formData: FormDataType[]
Form data.
example:

[
{
"marker": "name",
"type": "string",
"value": "Test"
}
]

id: number
The unique identifier of the form page.
example: 12345

actionMessage: string | null
Action message for the form data.
example: "Form submitted successfully"

attributeSetIdentifier: string | null
Text identifier (marker) of the used attribute set.
example: "product_attributes"