Material management v1

Last updated:2021-12-15
Expand all
Material management v1

API Overview

Function description

right UMS The system’s internal materials and materials from third-party platforms are managed. API, you can upload pictures, videos, files and other materials.

Currently, only uploading attachments is supported, which is used for sending emails with attachments.

Calling address

POST https://api.ums.jiguang.cn/v1/material

Call verification

HTTP Header(Header) Add a field ( Key/Value right):

Authorization: Basic base64_auth_string

in base64_auth_string The generation algorithm is:base64(ChannelKey:MasterSecret) That is, to ChannelKey Add a colon, add MasterSecret Assemble the string and then do base64 Convert.

Upload material

Upload an attachment in the form of a form,Content-Type: multipart/form-data

parameter type Options illustrate
type String Required Material type, currently only supports attachment 1 type, representing attachments.
file File Required Only 1 file allowed to be uploaded at a time
time_to_live int Optional Material validity period, the default value is 24 hours. For attachment types, the valid value range that can be passed is [1,168] time, that is, 1 hour to168hours (7 days)

Example description

Request example

curl --location --request POST 'https://api.ums.jiguang.cn/v1/material' \ --header 'Authorization: Basic N2Q0MzFlNDJkZmE2YTZkNjkzYWMyZDA0OjVlOTg3YWM2ZDJlMDRkOTVhOWQ4ZjBkMQ==' \ --form 'file=@"/D:/ums.pdf"' \ --form 'type="attachment"' \ --form 'time_to_live="169"'
          curl --location --request POST 'https://api.ums.jiguang.cn/v1/material' \
--header 'Authorization: Basic N2Q0MzFlNDJkZmE2YTZkNjkzYWMyZDA0OjVlOTg3YWM2ZDJlMDRkOTVhOWQ4ZjBkMQ==' \
--form 'file=@"/D:/ums.pdf"' \
--form 'type="attachment"' \
--form 'time_to_live="169"'

        
This code block is shown in the floating window

Return parameters and examples

parameter type Options illustrate
code int Required Business status code, 0 represents success, others represent failure, see call return code for details
url String Required When the upload is successful, the address of the file will be returned.
For attachments: this address can only be used to pass values ​​when sending messages, and cannot directly request downloads.
message String Optional Reason for failure, returned on failure
< HTTP/1.1 200 OK < Content-Type: application/json { "code": 0, "url": "https://jg-ums-inside.obs.cn-north-4.myhuaweicloud.com:443/ums123" }
          < HTTP/1.1 200 OK
< Content-Type: application/json
{
 "code": 0,
 "url": "https://jg-ums-inside.obs.cn-north-4.myhuaweicloud.com:443/ums123"
}

        
This code block is shown in the floating window
{"code":1015113,"message":"素材类型不合法,请修改后重试"}
          {"code":1015113,"message":"素材类型不合法,请修改后重试"}

        
This code block is shown in the floating window

Use uploaded assets

Here is a brief introduction on how to attach attachments when sending emails. For more details on the message sending function, seeOrdinary message sending

When sending an ordinary message, the msg_email Added files field, multiple attachments can be uploaded at one time URL address.

curl https://api.ums.jiguang.cn/v1/sent -v -X POST -u '10000023A1:750d8f613e13464e942e8bc2' -d ' { "aud_email": [{ "instance": "email", "data": [ "support@jiguang.cn" ] }], "msg_email": [{ "subject": "hello, ums email!", "text": "ums email test. reply", "files": ["https://jg-ums-inside.obs.cn-north-4.myhuaweicloud.com:443/ums123","填写url2"] }], "option": { "sendno": "test_mail", "expire_time": 1602523317, "priority": 2 } }
          curl https://api.ums.jiguang.cn/v1/sent -v -X POST -u '10000023A1:750d8f613e13464e942e8bc2' -d '
{
 "aud_email": [{
 "instance": "email",
 "data": [
 "support@jiguang.cn"
 ]
 }],
 "msg_email": [{
 "subject": "hello, ums email!",
 "text": "ums email test. reply",
 "files": ["https://jg-ums-inside.obs.cn-north-4.myhuaweicloud.com:443/ums123","填写url2"]
 }],
 "option": {
 "sendno": "test_mail",
 "expire_time": 1602523317,
 "priority": 2
 }
}

        
This code block is shown in the floating window

call returns

call API Please refer to the return code afterBusiness return code

refer to

Was this document helpful?

Copyright 2011-2026, jiguang.cn, All Rights Reserved. 粤ICP备12056275号-13 Shenzhen Hexun Huagu Information Technology Co., Ltd.

Open in Docs Center