Skip to main content

postFormsData

Creating an object of form data to save information

FormData.postFormsData(data, langCode)

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


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

{
"marker": "last_name",
"type": "string",
"value": "Username"
}

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

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

Example with a simple type attribute "text"

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

Example with a simple type attribute "textWithHeader"

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

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

{
"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
}
}
]
}

Example with a simple type attribute "files"

{
"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
}
]
}

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

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

Example with attribute type "entity" (nested list)

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

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"

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

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

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

const value = await FormData.postFormsData(body)
Schema (body)

formIdentifier: string
Text identifier of the form object (marker)
example: my-form

formData: FormDataLangType
Data submitted by the form
example:

[
{
"marker": "name_field",
"type": "string",
"value": "Name"
}
]

fileQuery: object
fileQuery for uploading files with the form
example:

{
"type": "page",
"entity": "editor",
"id": 3492,
}

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

Example return:

{
"id": 1764,
"formIdentifier": "my-form",
"time": "2025-05-09T18:32:46.834Z",
"formData": {
"marker": "name_1",
"value": "Name",
"type": "string"
}
}
Schema

id: number
object identifier
example: 1764

formIdentifier: string
Text identifier of the form object (marker)
example: my-form

time: Date
Date and time of form modification
example: 2025-05-09T18:32:46.834Z

formData: FormDataLangType
Data submitted by the form
example:

  [
{
"marker": "marker_1",
"value": "Name"
}
]