Call this operation to publish a message to a specified topic.

Request parameters

Parameter Type Required Description
Action String Yes The operation that you want to perform. Set the value to Pub.
ProductKey String Yes The ProductKey of the device that publishes this message.
TopicFullName String Yes

The topic that receives messages, such as /a1Q5XoY****/device1/user/update.

  • System topics are not supported.
  • The specified topic must have the Publish or Publish and Subscribe permissions.

You can call QueryProductTopic to query the topic categories of the product. You can also go to the Topic List tab page of the Device Details page to view the topics of the device.

MessageContent String Yes The body of the message to be published. To generate the message body, you must convert the raw message into binary data and perform Base64 encoding.
Qos Integer No

Specifies the QoS of message sending. Valid values:

0: Indicates that the message is published at most one time.

1: Indicates that the message is published at least one time.

If you do not specify this parameter, the value is 0.

Note QoS=1 messages can be stored in IoT Platform for up to 7 days. IoT Platform does not store QoS=0 messages.
Common request parameters N/A Yes See Common parameters.

Response parameters

Parameter Type Description
RequestId String The GUID generated by Alibaba Cloud for the request.
Success Boolean Indicates whether the call is successful. A value of true indicates that the call is successful. A value of false indicates that the call has failed.
ErrorMessage String The error message returned when the call fails.
Code String The error code returned when the call fails. For more information about error codes, see Error codes.
MessageId String The message ID generated by IoT Platform when the message is sent.


Sample requests
&Common request parameters

Sample responses

  • JSON format

  • XML format

    <? xml version="1.0" encoding="UTF-8"? >