Getting the Attachment List of the Attachment Library
This interface is used to obtain the attachment list of all or specified categories under a customer service.
Request Method
GET /knowledge_attachments
Request Parameters (Query String)
Parameter Name | Type | Required | Description | Restrictions |
---|---|---|---|---|
catalog_id | Integer | Yes | Common link category id | |
agent_id | Integer | Yes | ID of the owner of the common link category | |
page | Integer | No | Page number, starts from 1, default is 1 | |
per_page | Integer | No | Number of items per page, default is 20, maximum is 100 |
Notes:
- catalog_id: Specific category id or 0, 0 represents all
- agent_id: Specific customer service id or 0, 0 represents the administrator
Return Data
Attribute Name | Type | Description |
---|---|---|
code | Integer | Execution result code, 1000 represents success |
knowledge_attachments | Array | Attachment list |
meta | Object | Pagination related content, see Common Data |
knowledge_attachments Data Structure
Attribute Name | Type | Description |
---|---|---|
id | Integer | Attachment id |
file_name | String | Attachment name |
file_type | String | Attachment type |
file_size | String | Attachment size |
file_url | String | Attachment address |
catalog_id | Integer | Category id where the attachment is located |
Example
Request
curl https://demo.udesk.cn/open_api_v1/knowledge_attachments?email=admin@udesk.cn×tamp=1494474404&sign=6892f1b794071c260e1b1eac15df588fc919c9e86eb742affaa742ad6c03cb52&nonce=2d931510-d99f-494a-8c67-87feb05e1594&sign_version=v2&catalog_id=0&agent_id=0
Response
{
"code": 1000,
"knowledge_attachments": [
{
"id": 1,
"catalog_id": 9,
"file_name": "JPG.JPG",
"file_type": "image/jpeg",
"file_size": null,
"file_url": "https://qn-public.udesk.cn/1472632419-JPG.JPG"
},
{
"id": 2,
"catalog_id": 10,
"file_name": "JPG.JPG",
"file_type": "image/jpeg",
"file_size": null,
"file_url": "https://qn-public.udesk.cn/JPG.JPG"
},
{
"id": 3,
"catalog_id": null,
"file_name": "file.docx",
"file_type": "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
"file_size": "11858",
"file_url": "https://qn-public.udesk.cn/Fs65I3NAYnqt_URMYQB8NAwerWI3"
}
],
"meta": {
"current_page": 1,
"total_pages": 1,
"total_count": 3
}
}
Re-uploading Attachment
This interface is used to modify a specific attachment.
Request Method
PUT /knowledge_attachments/:id
Request Parameters (URL)
Parameter Name | Type | Required | Description | Restrictions |
---|---|---|---|---|
id | Integer | Yes | Common link id | |
file_name | String | Yes | Attachment file | |
type | String | Yes | Attachment file type | |
agent_id | Integer | Yes | ID of the attachment creator |
Notes:
- The value of agent_id is the specific customer service id or 0, 0 represents the administrator
- Specify Content-type:application/octet-stream in the request, convert the uploaded file into a stream file and place it in the request body
- Make sure the file type type is correct, otherwise the file cannot be recognized
Return Data
Attribute Name | Type | Description |
---|---|---|
id | Integer | Attachment id |
file_name | String | Attachment name |
file_type | String | Attachment type |
file_size | String | Attachment size |
file_url | String | Attachment address |
catalog_id | Integer | Category id where the attachment is located |
Example
Request
curl https://demo.udesk.cn/open_api_v1/knowledge_attachments?email=admin@udesk.cn×tamp=1494474404&sign=6892f1b794071c260e1b1eac15df588fc919c9e86eb742affaa742ad6c03cb52&nonce=2d931510-d99f-494a-8c67-87feb05e1594&sign_version=v2&file_name=aaa&type=jpg&agent_id=0&catalog_id=10 \
-X PUT \
-H 'content-type: appliacation/json' \
-d '
'
Response
{
"code": 1000,
"id": 5,
"catalog_id": 10,
"file_name": "9747.jpg_wh300.jpg",
"file_type": "jpg",
"file_size": 79044,
"file_url": "https://qn-public.udesk.cn/Fk8NQDfDUqbImbZvD37VVDejCNfv"
}
Creating a New Attachment
This interface is used to create a new attachment in a specific category of a customer service.
Request Method
POST /knowledge_attachments
Request Parameters (Request URL)
Parameter Name | Type | Required | Description | Restrictions |
---|---|---|---|---|
file_name | String | Yes | Attachment name | |
type | String | Yes | Attachment file type | |
catalog_id | Integer | Yes | Attachment category id | |
agent_id | Integer | Yes | ID of the attachment creator |
Notes:
- catalog_id: Specific category id
- agent_id: Specific customer service id or 0, 0 represents the administrator
- Specify Content-type:application/octet-stream in the request, convert the uploaded file into a stream file and place it in the request body
- Make sure the file type type is correct, otherwise the file cannot be recognized
Return Data
Attribute Name | Type | Description |
---|---|---|
id | Integer | Attachment id |
file_name | String | Attachment name |
file_type | String | Attachment type |
file_size | String | Attachment size |
file_url | String | Attachment address |
catalog_id | Integer | Category id where the attachment is located |
Example
Request
curl https://demo.udesk.cn/open_api_v1/knowledge_attachments?email=admin@udesk.cn×tamp=1494474404&sign=6892f1b794071c260e1b1eac15df588fc919c9e86eb742affaa742ad6c03cb52&nonce=2d931510-d99f-494a-8c67-87feb05e1594&sign_version=v2&file_name=aaa&type=jpg&agent_id=0&catalog_id=10 \
-X POST \
-H 'content-type: appliacation/json' \
-d '
'
Response
{
"code": 1000,
"id": 4,
"catalog_id": 10,
"file_name": "9747.jpg_wh300.jpg",
"file_type": "jpg",
"file_size": 79044,
"file_url": "https://qn-public.udesk.cn/Fk8NQDfDUqbImbZvD37VVDejCNfv"
}
Deleting an Attachment
This interface is used to delete a specific attachment.
Request Method
DELETE /knowledge_attachments/:id
Request Parameters (URL)
Parameter Name | Type | Required | Description | Restrictions |
---|---|---|---|---|
id | Integer | Yes | Common link id | |
agent_id | Integer | Yes | ID of the common link creator |
Return Data
Attribute Name | Type | Description |
---|---|---|
code | Integer | Execution result code, 1000 represents success |
id | Integer | Common link id |
message | String | Result description |
Example
Request
curl https://demo.udesk.cn/open_api_v1/knowledge_attachments/4111?email=admin@udesk.cn×tamp=1494474404&sign=6892f1b794071c260e1b1eac15df588fc919c9e86eb742affaa742ad6c03cb52&nonce=2d931510-d99f-494a-8c67-87feb05e1594&sign_version=v2 \
-X DELETE \
-H 'content-type: appliacation/json' \
-d '
{
"agent_id": 12
}
'
Response
{
"code": 1000,
"id": "4111",
"message": "Attachment deletion successful"
}