How Do I Obtain the Callback URL When Calling the Subscription API
The following assumes that an NA subscribes to device data changes. The process of subscription and push is as follows:
- The NA calls the subscription API of the IoT platform to subscribe to device data changes (the request carries the callback URL and notification type). The IoT platform stores the callback URL and the notification type in the subscription list.
- The device reports data to the IoT platform.
- Based on the callback URL stored during the subscription, the IoT platform automatically pushes the device data to the NA.
What Is a Callback URL?
The callback URL is the RESTful API address defined by the NA for external access. When the IoT platform pushes message to the NA, it calls the RESTful API of the NA to send data to the NA.
The request method of the callback URL must be POST.
How Do I Obtain a Callback URL?
The callback URL consists of the communication mode, access address of the NA, and URL of the RESTful API. An example value is https://server:port/url.
HTTPS is recommended to secure the communication between the NA and IoT platform. When HTTPS is used for communication, the IoT platform must load a certificate and export the HTTPS push certificate. For details, see How Do I Export the HTTPS Push Certificate.
The access address of the NA varies according to the network where the NA is located.
- If the NA is deployed on the public network, the access address of the NA is the public IP address of the NA:port (or domain name:port).
- If the NA is deployed on the LAN, you must configure network penetration on the NA to generate the public network access address of the NA. For details, obtain the configuration procedure of the network penetration tool from the Internet.
The callback URL can be the same or different for subscription of different notification types. It can be self-defined according to service requirements.