消息通知

创建消息通知

POST /v1/notify

此接口用于创建消息通知,可携带附件,支持一次上传多个文件,具体请参考请求示例

请求参数
参数 类型 必填 说明
subject 字符串 通知标题,长度20
content 字符串 通知内容,支持富文本,长度500.
userEmails 字符串 接收对象-邮件(接收对象必填一个),多个用英文逗号隔开,最大1000.
userGroupIds 字符串 接收对象-用户组id(接收对象必填一个),多个用英文逗号隔开,最大1000.
响应数据
属性名 类型 说明
code 整型 响应编码.
message 字符串 响应消息.
visible 布尔型 是否可见. true / false .
data 整型 通知编号.
请求体
{
    "subject": "消息标题",
    "content": "<p>消息内容</p>",
    "userEmails": "ab@shh.cn,cd@shh.cn",
    "userGroupIds": "41,235"
}
请求示例
curl --location -g --request POST 'https://servicego.udesk.cn/api/v1/notify?email=1@test.cn&timestamp=1662108548&sign=bc2e966cf693478b522ed5659907c761b3877845' \
--form 'files=@"/C:/Users/admin/Desktop/______.txt"' \
--form 'files=@"/C:/Users/admin/Desktop/batch.txt"' \
--form 'notifyRequest="{
    \"subject\": \"消息标题postman\",
    \"content\": \"<p>消息内容,无附件jhjhjsssss</p>\",
    \"userEmails\": \"1@shh.cn,1@test.cn\",
    \"userGroupIds\":\"1,2\"
}";type=application/json'
请求示例(java)
public static void main(String[] args) throws IOException {
    CloseableHttpClient httpClient = HttpClients.createSystem();

    MultipartEntityBuilder multipartEntityBuilder = MultipartEntityBuilder.create().setMode(HttpMultipartMode.RFC6532);
    multipartEntityBuilder.addBinaryBody("files", new FileInputStream("C:\\Users\\admin\\Desktop\\right.txt"), ContentType.MULTIPART_FORM_DATA, "right.txt");
    multipartEntityBuilder.addBinaryBody("files", new FileInputStream("C:\\Users\\admin\\Desktop\\sql.txt"), ContentType.MULTIPART_FORM_DATA, "sql.txt");
    multipartEntityBuilder.addTextBody("notifyRequest", "{\"subject\":\"消息标题\",\"content\":\"<p>消息内容</p>\",\"userEmails\":\"1@1.cn,2@q.cn\",\"userGroupIds\":\"1,2\"}", ContentType.APPLICATION_JSON);

    HttpEntity httpEntity = multipartEntityBuilder.build();
    HttpPost httpPost = new HttpPost(URI.create("https://servicego.udesk.cn/api/v1/notify?email=1@shh.cn&timestamp=1661306744&sign=f11983aaea9a597f5c45bde9393ad151d79c88c37e9fa2b13c2e6a8706bfeabf"));
    httpPost.setEntity(httpEntity);

    CloseableHttpResponse execute = httpClient.execute(httpPost);
    System.out.println("响应状态:" + execute.getStatusLine().getStatusCode());
    System.out.println("响应数据:" + StreamUtils.copyToString(execute.getEntity().getContent(), StandardCharsets.UTF_8));

}
响应示例
{
  "code" : 200,
  "message" : "OK",
  "visible" : false,
  "data" : 12
}