When a device reports a message, it needs to carry ProductId
, DeviceName
, and TopicName
to initiate an http/https
request to the platform. The request API and parameters are as detailed below:
Requested URL:https://ap-guangzhou.gateway.tencentdevices.com/device/publish
http://ap-guangzhou.gateway.tencentdevices.com/device/publish
Request method: POST
Parameter | Required | Type | Description |
---|---|---|---|
ProductId | Yes | String | Product ID |
DeviceName | Yes | String | Device name |
TopicName | Yes | String | Name of the topic for publishing the message |
Payload | Yes | String | Content of the published message |
PayloadEncoding | No | String | Encoding for the published message. Currently, only Base64-encoding is supported. If this parameter is left empty, the original message content will be sent. |
Qos | Yes | Integer | Message QoS level |
Note:The API only supports the
application/json
format.
There are two types of signatures for request messages. Key authentication uses the HMACSHA256 algorithm, and certificate authentication uses the RSA_SHA256 algorithm. For more information, please see Signature Algorithm.
Parameter | Type | Description |
---|---|---|
RequestId | String | Request ID |
POST https://ap-guangzhou.gateway.tencentdevices.com/device/publish
Content-Type: application/json
Host: ap-guangzhou.gateway.tencentdevices.com
X-TC-Algorithm: HmacSha256
X-TC-Timestamp: 155****065
X-TC-Nonce: 5456
X-TC-Signature: 2230eefd229f582d8b1b891af7107b915972407****78ab3738f756258d7652c
{"DeviceName":"AAAAAA","Payload":"123","ProductId":"G8N****AHB","Qos":1,"TopicName":"G8N****AHB/AAAAAA/data"}
{
"Response": {
"RequestId": "f4da4f1f-d72e-40f1-****-349fc0072ba0"
}
}
Was this page helpful?