logo

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 NameTypeRequiredDescriptionRestrictions
catalog_idIntegerYesCommon link category id
agent_idIntegerYesID of the owner of the common link category
pageIntegerNoPage number, starts from 1, default is 1
per_pageIntegerNoNumber 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 NameTypeDescription
codeIntegerExecution result code, 1000 represents success
knowledge_attachmentsArrayAttachment list
metaObjectPagination related content, see Common Data

knowledge_attachments Data Structure

Attribute NameTypeDescription
idIntegerAttachment id
file_nameStringAttachment name
file_typeStringAttachment type
file_sizeStringAttachment size
file_urlStringAttachment address
catalog_idIntegerCategory id where the attachment is located

Example

Request

curl https://demo.udesk.cn/open_api_v1/knowledge_attachments?email=admin@udesk.cn&timestamp=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 NameTypeRequiredDescriptionRestrictions
idIntegerYesCommon link id
file_nameStringYesAttachment file
typeStringYesAttachment file type
agent_idIntegerYesID 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 NameTypeDescription
idIntegerAttachment id
file_nameStringAttachment name
file_typeStringAttachment type
file_sizeStringAttachment size
file_urlStringAttachment address
catalog_idIntegerCategory id where the attachment is located

Example

Request

curl https://demo.udesk.cn/open_api_v1/knowledge_attachments?email=admin@udesk.cn&timestamp=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 NameTypeRequiredDescriptionRestrictions
file_nameStringYesAttachment name
typeStringYesAttachment file type
catalog_idIntegerYesAttachment category id
agent_idIntegerYesID 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 NameTypeDescription
idIntegerAttachment id
file_nameStringAttachment name
file_typeStringAttachment type
file_sizeStringAttachment size
file_urlStringAttachment address
catalog_idIntegerCategory id where the attachment is located

Example

Request

curl https://demo.udesk.cn/open_api_v1/knowledge_attachments?email=admin@udesk.cn&timestamp=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 NameTypeRequiredDescriptionRestrictions
idIntegerYesCommon link id
agent_idIntegerYesID of the common link creator

Return Data

Attribute NameTypeDescription
codeIntegerExecution result code, 1000 represents success
idIntegerCommon link id
messageStringResult description

Example

Request

curl https://demo.udesk.cn/open_api_v1/knowledge_attachments/4111?email=admin@udesk.cn&timestamp=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"
}