Broadcasts a message to all devices of a specified product or all devices that subscribe to a specified topic.
Limits
- Each Alibaba Cloud account can run only 1 query per second (QPS) to broadcast a message to devices that subscribe to a topic.
- Each Alibaba Cloud account can run only 1 query per minute (QPM) to broadcast a message to all online devices of a product.
Debugging
Request parameters
Parameter | Type | Required | Example | Description |
---|---|---|---|---|
Action | String | Yes | PubBroadcast |
The operation that you want to perform. Set the value to PubBroadcast. |
MessageContent | String | Yes | aGVsbG93b3JsZA |
The body of the message to be sent. The maximum size of a message is 64 KB. To generate a message body, you must convert the raw message into binary data and perform Base64 encoding. |
ProductKey | String | Yes | aldeji3***** |
The ProductKey of the devices to which the message is broadcasted. |
IotInstanceId | String | No | iot_instc_pu****_c*-v64******** |
The ID of the instance. This parameter is not required for the public instance but required for Enterprise Edition instances. |
TopicFullName | String | No | /broadcast/UPqSxj2vXXX/xxx |
The name of the topic. This parameter is optional.
Note
|
In addition to the preceding operation-specific request parameters, you must specify common request parameters when you call this operation. For more information about common request parameters, see Common parameters.
Response parameters
Parameter | Type | Example | Description |
---|---|---|---|
Code | String | iot.system.SystemException |
The error code returned if the call fails. For more information, see Error codes. |
ErrorMessage | String | A system exception occurred. |
The error message returned if the call fails. |
MessageId | Long | 1234291569964771840 |
The ID of the message. The message ID is generated by IoT Platform when the message is sent. |
RequestId | String | BB71E443-4447-4024-A000-EDE09922891E |
The ID of the request. |
Success | Boolean | true |
Indicates whether the call was successful.
|
Examples
Sample requests
https://iot.cn-shanghai.aliyuncs.com/?Action=PubBroadcast
&ProductKey=al**********
&TopicFullName=/broadcast/UPqSxj2vXXX/xxx
&MessageContent=aGVsbG93b3JsZA
&<Common request parameters>
Sample success responses
XML
format
<PubBroadcastResponse>
<RequestId>BB71E443-4447-4024-A000-EDE09922891E</RequestId>
<MessageId>1234291569964771840</MessageId>
<Success>true</Success>
</PubBroadcastResponse>
JSON
format
{
"RequestId":"BB71E443-4447-4024-A000-EDE09922891E",
"MessageId":1234291569964771840,
"Success":true
}
Error codes
For a list of error codes, visit the API Error Center.