Batch import document content through API interface, supporting the import of complete information such as document title, content, category, keywords, thumbnails, etc., which can realize batch migration and publication of content.
Precautions
- This interface uses the POST method to submit data in form-data format
- The token parameter must be provided in the URL for authentication
- The document title, content, and category ID must be provided
- Supports custom URL alias, keywords, description, thumbnail, and other complete document information
- Support document group image upload, up to 9 images can be set
- Can set document publication time, supports scheduled publication function
- Supports document Tag tag setting, multiple tags are separated by English commas
- Choose whether to save as a draft or overwrite the existing document
Request address
{域名地址}/api/import/archive?token={token}
Description:{域名地址}It needs to be replaced with your domain address.{token}It needs to be replaced with the Token from the backend content import interface feature.https://en.anqicms.com/api/import/archive?token=xxx
Request syntax
POST {域名地址}/api/import/archive?token={token}
Content-Type: multipart/form-data
Request header
| Field Name |
Type |
Required |
Description |
| Content-Type |
string |
Yes |
Must be set to multipart/form-data |
This interface also involves common request headers. For more information, please seeCommon Request Headers (Common Request Headers).
Request Parameters
URL parameters
| Field Name |
Type |
Required |
Description |
| token |
string |
Yes |
Token in the background content import interface function |
Form parameters
| Field Name |
Type |
Required |
Description |
| id |
integer |
No |
Document ID, automatically generated by default |
| Title |
string |
Yes |
Document Title |
| content |
string |
Yes |
Document Content |
| category_id |
integer |
Yes |
Document Category ID |
| Keywords |
string |
No |
Document keywords |
| Description |
string |
No |
Document summary, within 250 words |
| url_token |
string |
No |
Custom URL alias, only supports numbers and letters |
| Logo |
string |
No |
Thumbnail of the document, can be an absolute address or a relative address |
| images[] |
string |
No |
Article group, up to 9 images can be set, multiple images please repeat this field |
| publish_time |
string |
No |
Document publication time, format: 2006-01-02 15:04:05, can be a future time for scheduled publication |
| tag |
string |
No |
Document Tag label, multiple tags separated by English commas, for example: aaa,bbb,ccc |
| draft |
boolean |
No |
Whether to save to draft, true: save to draft, false: publish directly |
| cover |
integer |
No |
When the same title, ID document exists, whether to overwrite, 0: Do not overwrite and prompt an error, 1: Overwrite with the latest content, 2: Do not make a judgment |
Response Headers
This interface only involves public response headers. More information, please refer toCommon Request Headers (Common Request Headers).
Return parameters
| Field Name |
Type |
Description |
| code |
integer |
Error code |
| message |
string |
Error Description |
| data |
object |
Return data content |
data Parameter
| Field Name |
Type |
Description |
| id |
integer |
Document ID |
| URL |
string |
Document URL |
Example Usage
Request Example
POST /api/import/archive?token=4712a54b4c456bb29b7816d241db69a7 HTTP/1.1
Host: www.anqicms.com
Content-Type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW
------WebKitFormBoundary7MA4YWxkTrZu0gW
Content-Disposition: form-data; name="title"
欢迎使用AnqiCMS
------WebKitFormBoundary7MA4YWxkTrZu0gW
Content-Disposition: form-data; name="content"
<p>欢迎使用AnqiCMS,这是一款使用GoLang开发的企业站内容管理系统</p>
------WebKitFormBoundary7MA4YWxkTrZu0gW
Content-Disposition: form-data; name="category_id"
2
------WebKitFormBoundary7MA4YWxkTrZu0gW
Content-Disposition: form-data; name="keywords"
AnqiCMS,内容管理,网站系统
------WebKitFormBoundary7MA4YWxkTrZu0gW
Content-Disposition: form-data; name="description"
安企内容管理系统(AnqiCMS)是一款优秀的企业站内容管理系统
------WebKitFormBoundary7MA4YWxkTrZu0gW
Content-Disposition: form-data; name="images[]"
https://en.anqicms.com/static/default/images/logo.png
------WebKitFormBoundary7MA4YWxkTrZu0gW--
Example of a request with custom fields
POST /api/import/archive?token=4712a54b4c456bb29b7816d241db69a7 HTTP/1.1
Host: www.anqicms.com
Content-Type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW
------WebKitFormBoundary7MA4YWxkTrZu0gW
Content-Disposition: form-data; name="title"
产品介绍
------WebKitFormBoundary7MA4YWxkTrZu0gW
Content-Disposition: form-data; name="content"
<p>这是产品详细介绍内容</p>
------WebKitFormBoundary7MA4YWxkTrZu0gW
Content-Disposition: form-data; name="category_id"
1
------WebKitFormBoundary7MA4YWxkTrZu0gW
Content-Disposition: form-data; name="price"
999
------WebKitFormBoundary7MA4YWxkTrZu0gW
Content-Disposition: form-data; name="stock"
100
------WebKitFormBoundary7MA4YWxkTrZu0gW--
Successful response example
{
"code": 0,
"msg": "发布成功",
"data": {
"id": 1,
"url": "https://en.anqicms.com/anqicms"
}
}
Successfully responded to overlay mode example
{
"code": 0,
"msg": "文档已更新",
"data": {
"id": 1,
"url": "https://en.anqicms.com/anqicms"
}
}
Error response example
{
"code": -1,
"msg": "分类ID不存在",
"data": null
}
Error Code
| Error code |
Description |
| 0 |
OK |
| -1 |
Error, the reason is indicated in msg |
| 1001 |
Not logged in |
| 1002 |
Unauthorized |
| 200 |
API request OK |