Skip to content

HTTP Post 数据转发

HTTP Post 转发会在平台收到设备数据后,将数据以 HTTP POST 请求发送到你配置的 Webhook 地址。适合对接业务服务器、自动化平台、云函数和自建数据处理服务。

Overview

When your devices report data to YenGear IoT Cloud, the platform can automatically forward that data to your specified URL via HTTP POST requests.

【配图占位:设备数据通过 HTTP Post 推送到业务服务器的数据流图】

Quick Start

Step 1: Create a Forwarding Profile

  1. Go to Org → Data Forwarding
  2. Click + New Profile
  3. Select HTTP Post as the type
  4. Enter your webhook URL
  5. Click Save

【配图占位:HTTP Post 转发配置弹窗截图】

Step 2: Test Your Configuration

Before using your production endpoint, you can test with the built-in test endpoint:

  1. In the profile card, find the Test Endpoint section
  2. Copy the Test URL provided
  3. Create a new profile using this test URL
  4. Send data from your device
  5. Click View Test Data to see received payloads in JSON format

【配图占位:HTTP Post 测试地址和测试数据查看区域截图】

Note: Test endpoints store up to 50 records per organization. Older records are automatically removed.

Step 3: Verify Data Reception

Once configured, your endpoint will receive POST requests containing device data.

Request Format

HTTP Headers

HeaderValue
Content-Typeapplication/json
AuthorizationBearer <secret_key> (if configured)

Request Body

The request body is a JSON array containing one or more data points:

json
[
  {
    "point_id": "POINT_ID_FROM_PLATFORM",
    "t": 1709856000,
    "value": 25.5,
    "the_type": 2001,
    "org_id": "your-org-slug"
  },
  {
    "point_id": "POINT_ID_FROM_PLATFORM",
    "t": 1709856000,
    "value": 65.2,
    "the_type": 2002,
    "org_id": "your-org-slug"
  }
]

Field Descriptions

FieldTypeDescription
point_idstring点位标识,以平台实际发送字段为准
tintegerUnix timestamp (seconds)
valuenumber点位数值
the_typeinteger点位类型
org_idstringOrganization slug

多点位示例

json
[
  {
    "point_id": "POINT_ID_FROM_PLATFORM",
    "t": 1709856000,
    "value": 25.5,
    "the_type": 2001,
    "org_id": "my-org"
  },
  {
    "point_id": "POINT_ID_FROM_PLATFORM",
    "t": 1709856000,
    "value": 65.2,
    "the_type": 2002,
    "org_id": "my-org"
  },
  {
    "point_id": "POINT_ID_FROM_PLATFORM",
    "t": 1709856000,
    "value": 18.3,
    "the_type": 2001,
    "org_id": "my-org"
  }
]

Configuration Options

When creating an HTTP Post profile, you can configure:

OptionRequiredDescription
URLYesYour webhook endpoint URL
Secret KeyNoFor request authentication
NameNoA friendly name for this profile
PriorityNoExecution order (higher = earlier)

【配图占位:HTTP Post 配置字段说明截图】

Implementing Your Endpoint

To receive data from YenGear IoT Cloud, your endpoint should:

  1. Accept POST requests
  2. Parse the JSON array from the request body
  3. Return a 2xx status code on success

Example: Node.js (Express)

javascript
const express = require('express');
const app = express();

app.use(express.json());

const SECRET_KEY = 'your-secret-key';

app.post('/webhook/iot-data', (req, res) => {
  // Verify authorization (optional)
  const authHeader = req.headers['authorization'];
  if (SECRET_KEY && authHeader !== `Bearer ${SECRET_KEY}`) {
    return res.status(401).json({ error: 'Unauthorized' });
  }
  
  // Process data array
  const dataPoints = req.body;
  dataPoints.forEach(point => {
    console.log(`Point: ${point.point_id}`);
    console.log(`Value: ${point.value}`);
    console.log(`Timestamp: ${point.t}`);
  });
  
  res.json({ success: true });
});

app.listen(3000);

Example: Python (Flask)

python
from flask import Flask, request, jsonify

app = Flask(__name__)
SECRET_KEY = 'your-secret-key'

@app.route('/webhook/iot-data', methods=['POST'])
def receive_data():
    # Verify authorization (optional)
    auth_header = request.headers.get('Authorization', '')
    if SECRET_KEY and auth_header != f'Bearer {SECRET_KEY}':
        return jsonify({'error': 'Unauthorized'}), 401
    
    # Process data array
    data_points = request.json
    for point in data_points:
        print(f"Point: {point.get('point_id')}")
        print(f"Value: {point['value']}")
        print(f"Timestamp: {point['t']}")
    
    return jsonify({'success': True})

if __name__ == '__main__':
    app.run(port=3000)

Security

Request Authentication

If you set a Secret Key, each request includes an authorization header:

Authorization: Bearer <your-secret-key>

Use this to verify requests are from YenGear IoT Cloud.

Best Practices

  • Always use HTTPS endpoints
  • Set a Secret Key and verify the Authorization header
  • Return 2xx status codes for successful processing
  • Process requests quickly to avoid timeouts

Troubleshooting

ProblemSolution
No data receivedCheck the profile is Enabled and URL is correct
Connection errorsVerify your endpoint is publicly accessible
Authentication errorsVerify your Secret Key matches
Timeout errorsOptimize your endpoint response time

Use Cases

  • Custom Dashboards: Feed real-time data to your visualization tools
  • Automation: Trigger workflows in Zapier, Make, or n8n
  • Alerts: Send data to monitoring systems for threshold alerts
  • Data Lakes: Push data to your data processing pipelines

Need Help?

Contact us at hi@yengear.com for technical support.