请求相关-为请求添加附件

请求相关-为请求添加附件

API调用URL地址

http://<serverName>:<portNumber>/api/v3/attachments

示例:http://localhost:8080/api/v3/attachments

请求参数

方法:POST

请求参数:

参数名

位置

input_data

<JSON_String>

body

files

 <File Path>

body

authtoken

<API Key>

header


输入示例

 {

    "attachment":{
        "request":{
            "id":"86"
        }

    }

}
将附件添加到id为86的请求中

响应示例

 {

    "attachment": {
        "size""86.48KB",
        "file_name""需求1(1).png",
        "content_url""/api/v3/attachments/905",
        "id""905",
        "attachment_key""2075F83B-E217-4259-AE8F-CB5E4F8C749B"
    },
    "response_status": {
        "messages": [
            {
                "type""success",
                "message""附件添加成功",
                "status_code""200"
            }
        ],
        "status""success"
    }
}

Postman示例

 

Python脚本示例

#Python version - 3.9
#需要安装requests模块
import requests
 
url = "http://localhost:8080/api/v3/attachments"
headers = {"authtoken":"9CE7BCBF-EACC-4E10-BE6C-D9284163B4DC"}
files = {'file':open('C:\\Users\\18436\\Pictures\\需求1.png','rb')}
input_data = '''{
    "attachment": {
        "request": {
            "id": "86"
        }
    }
}'''
data = {'input_data'input_data}
response = requests.post(url,headers=headers,data=data,files=files,verify=False)
print(response.text)