Uploading an Attachment with form-data
Function
Upload attachments by using the form-data. The attachments to be uploaded must meet the restrictions, such as those on the attachment size, returned by the API for querying attachment restrictions.
URI
POST /v2/servicerequest/accessorys
Request Parameters
Parameter | Mandatory | Type | Description |
|---|---|---|---|
X-Auth-Token | Yes | String | Specifies the user token. It can be obtained by calling the IAM API (value of X-Subject-Token in the response header). Minimum length: 1 Maximum length: 5000 |
X-Language | No | String | Specifies the language environment. The value is a common language description character string, for example, zh-cn. It is zh-cn by default. Some internationalization information, such as the service ticket type and name, is displayed based on the language environment. Minimum length: 1 Maximum length: 32 |
X-Time-Zone | No | String | Specifies the time zone. The value is a common time zone description character string, for example, GMT+8. It is GMT+8 by default. Time-related data is processed based on the time zone of the environment. Minimum length: 1 Maximum length: 32 |
Parameter | Mandatory | Type | Description |
|---|---|---|---|
file | Yes | File | Specifies the file content. |
form_data | Yes | String | Specifies the attachment information, such as the file source (incident for service ticket creation and message for messages), file name, and upload type (default value: 0; markdown mode: 1). The format must be a JSON character string: {"fileName":"test.jpg","accessoryFrom":"incident","uploadType":0}. Minimum length: 1 Maximum length: 5000 |
Response Parameters
Status code: 200
Parameter | Type | Description |
|---|---|---|
accessory_id | String | Specifies the attachment ID. Minimum length: 1 Maximum length: 64 |
Request Example
POST https://{endpoint}/v2/servicerequest/accessorys
{
"form_data" : "{\"fileName\":\"test.txt\",\"accessoryFrom\":\"test\",\"uploadType\":0}",
"file" : "file"
} Response Example
Status code: 200
The ID of the attachment is returned if the upload is successful.
{
"accessory_id" : "123456"
} Status Codes
Status Code | Description |
|---|---|
200 | The ID of the attachment is returned if the upload is successful. |
Error Codes
See Error Codes.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.

