forked from docs/doc-exports
Reviewed-by: Bobkova, Natalia <natalia.bobkova@t-systems.com> Co-authored-by: Zaoxu, Li <lizaoxu@huawei.com> Co-committed-by: Zaoxu, Li <lizaoxu@huawei.com>
161 lines
13 KiB
HTML
161 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"><a name="smn_api_54003__li51147505203733"></a><a name="li51147505203733"></a>Publish</p>
|
|
</li></ul>
|
|
<ul id="smn_api_54003__ul20998054203745"><li id="smn_api_54003__li46884910203750">Function<p id="smn_api_54003__p4717288173954"><a name="smn_api_54003__li46884910203750"></a><a name="li46884910203750"></a>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"><a name="smn_api_54003__li22393088195031"></a><a name="li22393088195031"></a>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 the topic. You can obtain it by referring to <a href="en-us_topic_0036016755.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__b1180792741">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__b2101424426">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__b66195391">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">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__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 messages 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 by referring 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">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__p62233639195031">Map<String,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__p1647183114206">Variable parameters and values <strong id="smn_api_54003__b153020113528">Tags</strong> cannot be left blank. This parameter is mandatory when you use a message template to publish messages. The key in the dictionary is the parameter name in the message template and can contain a maximum of 21 characters. The value in the dictionary is the value after the key in the message template is replaced. The value cannot exceed 1 KB.</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__p69472513516">The maximum retention period of a message in SMN</p>
|
|
<p id="smn_api_54003__p9432154917146">After the retention period expires, SMN does not send this message.</p>
|
|
<p id="smn_api_54003__p145101952101414">Unit: second </p>
|
|
<p id="smn_api_54003__p66191571978">Default retention period: <strong id="smn_api_54003__b135483385289">3600</strong> (one hour)</p>
|
|
<p id="smn_api_54003__p163851021156">The retention period 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">Example request<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__b2060580873">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__b90623954">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__b2045305843">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">Example response<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 <a href="smn_api_63002.html">Returned Value</a>.</p>
|
|
</div>
|
|
<div class="section" id="smn_api_54003__section73211020122511"><h4 class="sectiontitle">Error Codes</h4><p id="smn_api_54003__p9759142919265">See <a href="smn_api_64000.html">Error Codes</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>
|
|
|