Get the field configuration information of the website message form, including field name, type, whether it is required, etc., for the dynamic generation of the message form on the front end.
Points to note
- This interface uses the GET method and no request parameters are required
- Returns all field configuration information of the message form
- Including field name, field type, whether required and other properties
- Supports various form field types: text, number, multi-line text, radio, checkbox, dropdown selection, image, file, etc.
- Can be used to dynamically render a message form on the front end
Request address
{域名地址}/api/guestbook/fields
Description:{域名地址}Replace it with your domain name, such ashttps://en.anqicms.com/api/guestbook/fields
Request Syntax
GET {域名地址}/api/guestbook/fields
Request Headers
This interface involves only public request headers. For more information, please refer toCommon Request Headers (Common Request Headers).
Request parameters
None
Response header
This interface only involves public response headers. For more information, please refer toCommon Request Headers (Common Request Headers).
Return parameters
| Field name | Type | Description |
|---|---|---|
| code | int | Error code |
| msg | string | Error description |
| data | object[] | Message form field list |
Parameters of data array elements
| Field name | Type | Description |
|---|---|---|
| name | string | Form Field Display Name |
| field_name | string | Form Field Invocation Name |
| type | string | Form field type, text: text, number: number, textarea: multiline text, radio: single choice, checkbox: multiple choice, select: drop-down selection, image: image, file: file |
| required | boolean | Is required, true: required, false: optional |
| content | string | Default value or option content of form field |
Usage Example
Request example
GET /api/guestbook/fields HTTP/1.1
Host: www.anqicms.com
Response Example
{
"code": 0,
"msg": "",
"data": [
{
"name": "用户名",
"field_name": "user_name",
"type": "text",
"required": true,
"content": ""
},
{
"name": "联系电话",
"field_name": "contact",
"type": "text",
"required": true,
"content": ""
},
{
"name": "留言内容",
"field_name": "content",
"type": "textarea",
"required": true,
"content": ""
},
{
"name": "性别",
"field_name": "gender",
"type": "radio",
"required": false,
"content": "男\n女\n保密"
}
]
}
error code
| Error code | Description |
|---|---|
| 0 | OK |
| -1 | Error, the reason is indicated in msg |
| 1001 | Not logged in |
| 1002 | Not authorized |
| 200 | API request OK |