Document Import Interface

Import document content in batches through the API interface, supporting the import of complete information such as document title, content, classification, keywords, thumbnails, etc., and can achieve batch migration and publication of content.

Points to note

  • This interface uses the POST method to submit data in form-data format
  • You must provide a valid token parameter in the URL for authentication
  • You must provide the document title, content, and category ID
  • Support custom URL alias, keywords, description, thumbnails, and complete document information.
  • Support uploading document group images, up to 9 images can be set.
  • Can set document publishing time, supports timed publishing function
  • Supports document Tag tag setting, multiple tags separated by English commas
  • Can choose whether to save as draft or overwrite the existing document

Request address

{域名地址}/api/import/archive?token={token}

Description:{域名地址}Replace with your domain address,{token}Need to be replaced with the Token from the background content import interface, such ashttps://en.anqicms.com/api/import/archive?token=xxx

Request Syntax

POST {域名地址}/api/import/archive?token={token}
Content-Type: multipart/form-data

Request Headers

Field name Type Required Description
Content-Type string Is Must be set to multipart/form-data

This interface also involves common request headers. For more information, please refer toCommon Request Headers (Common Request Headers).

Request parameters

URL parameters

Field name Type Required Description
token string Is Token in the background content import interface feature

Form parameters

Field name Type Required Description
id int No Document ID, generated automatically by default
Title string Is Document title
content string Is Document content
category_id int Is Document Category ID
keywords string No Document keyword
description string No Document summary, within 250 words
URL Token string No Custom URL alias, supports numbers and letters only
Logo string No Document thumbnail, can be an absolute or relative address
images[] string No Article gallery, up to 9 images can be set, repeat this field for multiple images
publish_time string No The document's publish time, formatted as: 2006-01-02 15:04:05, can be set for timed release in the future
tag string No Document Tag label, multiple tags separated by English comma, for example: aaa,bbb,ccc
draft boolean No Whether to save to draft, true: save to draft, false: publish directly
cover int No When the document with the same title and ID exists, whether to overwrite, 0: Do not overwrite and prompt an error, 1: Overwrite with the latest content, 2: Do not judge

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 Return data content

data parameter

Field name Type Description
id int Document ID
url string Document URL

Usage Example

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--

Request example with custom field

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

Example of successful response in overwrite mode

{
  "code": 0,
  "msg": "文档已更新",
  "data": {
    "id": 1,
    "url": "https://en.anqicms.com/anqicms"
  }
}

Example of error response

{
  "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 Not authorized
200 API request OK