forked from docs/doc-exports
Reviewed-by: gtema <artem.goncharov@gmail.com> Co-authored-by: guoyanyan <guoyanyan3@huawei.com> Co-committed-by: guoyanyan <guoyanyan3@huawei.com>
160 lines
13 KiB
HTML
160 lines
13 KiB
HTML
<a name="smn_api_54003"></a><a name="smn_api_54003"></a>
|
|
|
|
<h1 class="topictitle1">Publishing Messages Using a Template</h1>
|
|
<div id="body1471602451370"><div class="section" id="smn_api_54003__section52611782195031"><h4 class="sectiontitle">Description</h4><ul id="smn_api_54003__ul33304380203733"><li id="smn_api_54003__li51147505203733">API name<p id="smn_api_54003__p38624841203741">Publish</p>
|
|
</li></ul>
|
|
<ul id="smn_api_54003__ul20998054203745"><li id="smn_api_54003__li46884910203750">Function<p id="smn_api_54003__p4717288173954">Use the message template to publish a message to a topic. After the message ID is returned, the message has been saved and is to be pushed to the subscribers of the topic. This API allows you to send messages to different types of subscribers using different template protocols with the same name.</p>
|
|
</li></ul>
|
|
</div>
|
|
<div class="section" id="smn_api_54003__section34827906195031"><h4 class="sectiontitle">URI</h4><ul id="smn_api_54003__ul2488120195031"><li id="smn_api_54003__li22393088195031">URI format<p class="tabletext" id="smn_api_54003__p211204195031">POST /v2/{project_id}/notifications/topics/{topic_urn}/publish</p>
|
|
</li></ul>
|
|
<ul id="smn_api_54003__ul1900836195031"><li id="smn_api_54003__li17107531195031">Parameter description
|
|
<div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" id="smn_api_54003__table19750057195031" frame="border" border="1" rules="all"><thead align="left"><tr id="smn_api_54003__row6202146195031"><th align="left" class="cellrowborder" valign="top" width="17.441744174417444%" id="mcps1.3.2.3.1.1.1.5.1.1"><p id="smn_api_54003__p32611809195031"><strong id="smn_api_54003__b842352706191030">Parameter</strong></p>
|
|
</th>
|
|
<th align="left" class="cellrowborder" valign="top" width="18.6018601860186%" id="mcps1.3.2.3.1.1.1.5.1.2"><p id="smn_api_54003__p24310897195031"><strong id="smn_api_54003__b593421527191713">Mandatory</strong></p>
|
|
</th>
|
|
<th align="left" class="cellrowborder" valign="top" width="18.6018601860186%" id="mcps1.3.2.3.1.1.1.5.1.3"><p id="smn_api_54003__p23025658195031"><strong id="smn_api_54003__b84235270619112">Type</strong></p>
|
|
</th>
|
|
<th align="left" class="cellrowborder" valign="top" width="45.35453545354536%" id="mcps1.3.2.3.1.1.1.5.1.4"><p id="smn_api_54003__p53138979195031"><strong id="smn_api_54003__b84235270619115">Description</strong></p>
|
|
</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody><tr id="smn_api_54003__row14292854195031"><td class="cellrowborder" valign="top" width="17.441744174417444%" headers="mcps1.3.2.3.1.1.1.5.1.1 "><p id="smn_api_54003__p16870512195031">project_id</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="18.6018601860186%" headers="mcps1.3.2.3.1.1.1.5.1.2 "><p id="smn_api_54003__p24334251195031">Yes</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="18.6018601860186%" headers="mcps1.3.2.3.1.1.1.5.1.3 "><p id="smn_api_54003__p24917327195031">String</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="45.35453545354536%" headers="mcps1.3.2.3.1.1.1.5.1.4 "><p id="smn_api_54003__p44538588155357">Project ID</p>
|
|
<p id="smn_api_54003__p5037570195031">See <a href="smn_api_66000.html">Obtaining a Project ID</a>.</p>
|
|
</td>
|
|
</tr>
|
|
<tr id="smn_api_54003__row48510570195031"><td class="cellrowborder" valign="top" width="17.441744174417444%" headers="mcps1.3.2.3.1.1.1.5.1.1 "><p id="smn_api_54003__p37042078195031">topic_urn</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="18.6018601860186%" headers="mcps1.3.2.3.1.1.1.5.1.2 "><p id="smn_api_54003__p47618335195031">Yes</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="18.6018601860186%" headers="mcps1.3.2.3.1.1.1.5.1.3 "><p id="smn_api_54003__p31879892195031">String</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="45.35453545354536%" headers="mcps1.3.2.3.1.1.1.5.1.4 "><p id="smn_api_54003__p32134437195031">Unique resource ID of a topic. You can obtain it according to <a href="smn_api_51004.html">Querying Topics</a>.</p>
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</li></ul>
|
|
</div>
|
|
<div class="section" id="smn_api_54003__section45105086195031"><h4 class="sectiontitle">Request</h4><ul id="smn_api_54003__ul29633365195031"><li id="smn_api_54003__li65373700195031">Parameter description
|
|
<div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" id="smn_api_54003__table51492393195031" frame="border" border="1" rules="all"><thead align="left"><tr id="smn_api_54003__row30761845195031"><th align="left" class="cellrowborder" valign="top" width="23.627637236276374%" id="mcps1.3.3.2.1.1.1.5.1.1"><p id="smn_api_54003__p8681487195031"><strong id="smn_api_54003__b822464551">Parameter</strong></p>
|
|
</th>
|
|
<th align="left" class="cellrowborder" valign="top" width="20.65793420657934%" id="mcps1.3.3.2.1.1.1.5.1.2"><p id="smn_api_54003__p32111829195031"><strong id="smn_api_54003__b2083279393642">Mandatory</strong></p>
|
|
</th>
|
|
<th align="left" class="cellrowborder" valign="top" width="21.42785721427857%" id="mcps1.3.3.2.1.1.1.5.1.3"><p id="smn_api_54003__p50921393195031"><strong id="smn_api_54003__b890199867">Type</strong></p>
|
|
</th>
|
|
<th align="left" class="cellrowborder" valign="top" width="34.28657134286571%" id="mcps1.3.3.2.1.1.1.5.1.4"><p id="smn_api_54003__p30992136195031"><strong id="smn_api_54003__b544632927">Description</strong></p>
|
|
</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody><tr id="smn_api_54003__row66660173195031"><td class="cellrowborder" valign="top" width="23.627637236276374%" headers="mcps1.3.3.2.1.1.1.5.1.1 "><p id="smn_api_54003__p30764938195031">subject</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="20.65793420657934%" headers="mcps1.3.3.2.1.1.1.5.1.2 "><p id="smn_api_54003__p8932068195031">Yes</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="21.42785721427857%" headers="mcps1.3.3.2.1.1.1.5.1.3 "><p id="smn_api_54003__p52408898195031">String</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="34.28657134286571%" headers="mcps1.3.3.2.1.1.1.5.1.4 "><p id="smn_api_54003__p17262349195031">Message subject, which is presented as the email subject when SMN sends massages to email subscribers</p>
|
|
<p id="smn_api_54003__p56073004195031">The message subject cannot exceed 512 bytes.</p>
|
|
</td>
|
|
</tr>
|
|
<tr id="smn_api_54003__row34894991195031"><td class="cellrowborder" valign="top" width="23.627637236276374%" headers="mcps1.3.3.2.1.1.1.5.1.1 "><p id="smn_api_54003__p7921992195031">message_template_name</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="20.65793420657934%" headers="mcps1.3.3.2.1.1.1.5.1.2 "><p id="smn_api_54003__p37701577195031">Yes</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="21.42785721427857%" headers="mcps1.3.3.2.1.1.1.5.1.3 "><p id="smn_api_54003__p33928891195031">String</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="34.28657134286571%" headers="mcps1.3.3.2.1.1.1.5.1.4 "><p id="smn_api_54003__p63885637195031">Message template name, which can be obtained according to <a href="smn_api_53004.html">Querying Message Templates</a></p>
|
|
<div class="note" id="smn_api_54003__note72738487427"><span class="notetitle"> NOTE: </span><div class="notebody"><p id="smn_api_54003__p27477201192714">Three message formats are supported:</p>
|
|
<ul id="smn_api_54003__ul13774005193124"><li id="smn_api_54003__li48569116193128">message</li><li id="smn_api_54003__li541604193131">message_structure</li><li id="smn_api_54003__li5438053519329">message_template_name</li></ul>
|
|
<p id="smn_api_54003__p4935176193233">If the three formats are specified at the same time, they take effect in the following sequence:</p>
|
|
<p id="smn_api_54003__p24212931193236">message_structure>message_template_name>message</p>
|
|
</div></div>
|
|
</td>
|
|
</tr>
|
|
<tr id="smn_api_54003__row66187157195031"><td class="cellrowborder" valign="top" width="23.627637236276374%" headers="mcps1.3.3.2.1.1.1.5.1.1 "><p id="smn_api_54003__p59559524195031">tags</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="20.65793420657934%" headers="mcps1.3.3.2.1.1.1.5.1.2 "><p id="smn_api_54003__p59592135195031">Yes</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="21.42785721427857%" headers="mcps1.3.3.2.1.1.1.5.1.3 "><p id="smn_api_54003__p62233639195031">JSON key-value pair</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="34.28657134286571%" headers="mcps1.3.3.2.1.1.1.5.1.4 "><p id="smn_api_54003__p7759979195031">Variable parameters and values</p>
|
|
<p id="smn_api_54003__p755417206436">The value cannot be left blank.</p>
|
|
</td>
|
|
</tr>
|
|
<tr id="smn_api_54003__row78834110147"><td class="cellrowborder" valign="top" width="23.627637236276374%" headers="mcps1.3.3.2.1.1.1.5.1.1 "><p id="smn_api_54003__p23681125515">time_to_live</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="20.65793420657934%" headers="mcps1.3.3.2.1.1.1.5.1.2 "><p id="smn_api_54003__p23681626518">No</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="21.42785721427857%" headers="mcps1.3.3.2.1.1.1.5.1.3 "><p id="smn_api_54003__p18075392520">String</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="34.28657134286571%" headers="mcps1.3.3.2.1.1.1.5.1.4 "><p id="smn_api_54003__p66191571978">TTL of a message, specifically, the maximum time period for retaining the message in the system</p>
|
|
<p id="smn_api_54003__p73858218511">If the period expires, the system will discard the message. The time period is measured in seconds, and the default TTL is <strong id="smn_api_54003__b84235270617311">3600s</strong> (one hour).</p>
|
|
<p id="smn_api_54003__p163851021156">The value must be a positive integer less than or equal to 604,800 (3600 x 24 x 7).</p>
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</li><li id="smn_api_54003__li19880412195031">Request example<pre class="screen" id="smn_api_54003__screen63751833105328">POST https://{SMN_Endpoint}/v2/{project_id}/notifications/topics/urn:smn:regionId: f96188c7ccaf4ffba0c9aa149ab2bd57:test_create_topic_v2/publish</pre>
|
|
<pre class="screen" id="smn_api_54003__screen6401874119510">{
|
|
"subject": "test message template v2",
|
|
"message_template_name": "confirm_message",
|
|
"time_to_live":"3600",
|
|
"tags": {
|
|
"topic_urn": "topic_urn3331",
|
|
"topic_id": "topic_id3332"
|
|
}
|
|
}</pre>
|
|
</li></ul>
|
|
</div>
|
|
<div class="section" id="smn_api_54003__section12227696195031"><h4 class="sectiontitle">Response</h4><ul id="smn_api_54003__ul50919299195031"><li id="smn_api_54003__li55620508195031">Parameter description
|
|
<div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" id="smn_api_54003__table30822526195031" frame="border" border="1" rules="all"><thead align="left"><tr id="smn_api_54003__row47162257195031"><th align="left" class="cellrowborder" valign="top" width="37.70622937706229%" id="mcps1.3.4.2.1.1.1.4.1.1"><p id="smn_api_54003__p62046506195031"><strong id="smn_api_54003__b175458084">Parameter</strong></p>
|
|
</th>
|
|
<th align="left" class="cellrowborder" valign="top" width="27.257274272572747%" id="mcps1.3.4.2.1.1.1.4.1.2"><p id="smn_api_54003__p59711095195031"><strong id="smn_api_54003__b349188857">Type</strong></p>
|
|
</th>
|
|
<th align="left" class="cellrowborder" valign="top" width="35.03649635036496%" id="mcps1.3.4.2.1.1.1.4.1.3"><p id="smn_api_54003__p4760545195031"><strong id="smn_api_54003__b128559554">Description</strong></p>
|
|
</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody><tr id="smn_api_54003__row28316458195031"><td class="cellrowborder" valign="top" width="37.70622937706229%" headers="mcps1.3.4.2.1.1.1.4.1.1 "><p id="smn_api_54003__p11931737195031">request_id</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="27.257274272572747%" headers="mcps1.3.4.2.1.1.1.4.1.2 "><p id="smn_api_54003__p26946629195031">String</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="35.03649635036496%" headers="mcps1.3.4.2.1.1.1.4.1.3 "><p id="smn_api_54003__p35193301195031">Request ID, which is unique</p>
|
|
</td>
|
|
</tr>
|
|
<tr id="smn_api_54003__row20330496195031"><td class="cellrowborder" valign="top" width="37.70622937706229%" headers="mcps1.3.4.2.1.1.1.4.1.1 "><p id="smn_api_54003__p36157466195031">message_id</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="27.257274272572747%" headers="mcps1.3.4.2.1.1.1.4.1.2 "><p id="smn_api_54003__p43073653195031">String</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="35.03649635036496%" headers="mcps1.3.4.2.1.1.1.4.1.3 "><p id="smn_api_54003__p66413881195031">Message ID, which is unique</p>
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</li><li id="smn_api_54003__li30228340195031">Response example<pre class="screen" id="smn_api_54003__screen45425969195137">{
|
|
"message_id": "bf94b63a5dfb475994d3ac34664e24f2",
|
|
"request_id": "9974c07f6d554a6d827956acbeb4be5f"
|
|
}</pre>
|
|
</li></ul>
|
|
</div>
|
|
<div class="section" id="smn_api_54003__section340897195031"><h4 class="sectiontitle">Returned Value</h4><p id="smn_api_54003__p27612703195031">See section <a href="smn_api_63002.html">Returned Value</a>.</p>
|
|
</div>
|
|
<div class="section" id="smn_api_54003__section73211020122511"><h4 class="sectiontitle">Error Code</h4><p id="smn_api_54003__p9759142919265">See section <a href="smn_api_64000.html">Error Code</a>.</p>
|
|
</div>
|
|
</div>
|
|
<div>
|
|
<div class="familylinks">
|
|
<div class="parentlink"><strong>Parent topic:</strong> <a href="smn_api_54000.html">Message Publishing</a></div>
|
|
</div>
|
|
</div>
|
|
|