tencent cloud

IoT Hub

Release Notes and Announcements
Release Notes
Product Introduction
Overview
Features
Strengths
Use Cases
Use Limits
Basic Concepts
Getting Started
Quick Start
Scenario 1: Device Interconnection
Scenario 2: Device Status Reporting and Setting
MQTT.fx Connection Guide
Console Guide
Product Management
Rule Engine
Sub-account Access to IoT Hub
Firmware Upgrade
Resource Management
Certificate Management
Developer Manual
Feature Components
Signature Algorithm
Device Authentication
Device Connection Protocol
Gateway Subdevice
Message Communication
Device Shadow
Device Firmware Upgrade
Remote Device Configuration
Resource Management
Device Log Reporting
NTP Service
Device Connection Manual
Device Connection Overview
Connection Based on SDK for C
Connection Based on SDK for Android
Connection Based on SDK for Java
Connection Based on SDK for Python
API Documentation
History
Introduction
API Category
Making API Requests
Device Shadow APIs
Device APIs
CA Certificate APIs
Product APIs
Data Types
Error Codes
FAQs
General
Device Connection and Reporting
Rule Engine
Console
IoT Hub Policy
Privacy Policy
Data Privacy And Security Agreement
Glossary

HTTP-Based Device Connection

PDF
Focus Mode
Font Size
Last updated: 2024-12-27 15:44:26

Parameter Description

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

Request parameters

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.

Signature generation

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.

Platform response parameters

Parameter
Type
Description
RequestId
String
Request ID

Sample Code

Request packet

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 packet

{
"Response": {
"RequestId": "f4da4f1f-d72e-40f1-****-349fc0072ba0"
}
}



Help and Support

Was this page helpful?

Help us improve! Rate your documentation experience in 5 mins.

Feedback