HTTP | Subscribe and Notify Mechanism
Last updated
Last updated
Prerequisites
Have NGROK software. If you don't have it yet, please go to the following link NGROK.
Have Node JS. If you don't have it yet, please go to the following link Node JS.
Have POSTMAN. If you don't have it yet, please go to the following link POSTMAN.
Login to your Antares account via Antares Console https://console.antares.id
Create an App, if you already have one, ignore it to proceed to the next process.
Create Device, if you already have one, ignore it to proceed to the next process.
Start by writing the programme code to get data from ANTARES. You can use the following programme code: Copy the program code to your computer's local storage then save it in .js extension format. In this tutorial, we save it with monitor.js
Open a command prompt (windows) or terminal (linux)
Enter the directory of the programme code file you saved earlier
Run the programme code according to the image below.
The successful programme code can be seen as in the following image.
Having problems? If yes, execute the following syntax. Otherwise, ignore this process.
Install packages that are not yet installed.
Allow Access when running the programme code.
Start running NGROK. NGROK will help you to open your localhost to the public domain. Firstly, go to the NGROK directory. Make sure you have extracted it, so that it is in .exe file format.
Run NGROK using port 9000 in the following way:
Open the Device that you have created earlier. Click the Subscribe button and a pop up menu will appear.
Add /monitor to the end of the NGROK URL as below.
When you have successfully subscribed to it, a pop up will appear.
Let's check if your server is getting notifications with an emulator device using POSTMAN. Please open POSTMAN, and fill in all the parameters with the following information.
Field
Value
URL
https://platform.antares.id:8443/~/antares-cse/antares-id/your-project-name/your-device-name
or
https://platform.antares.id:8443/~/antares-cse/your-device-ID
Note: your-device-ID
must be starting with CNT
. e.g. CNT-842419289
Method
POST
Let's check if your server is getting notifications with an emulator device using POSTMAN. Please open POSTMAN, and fill in all the parameters with the following information.
Field
Value
URL
https://platform.antares.id:8443/~/antares-cse/antares-id/your-project-name/your-device-name
or
https://platform.antares.id:8443/~/antares-cse/your-device-ID
Note: your-device-ID
must be starting with CNT
. e.g. CNT-842419289
Method
POST
Header
Key
Value
X-M2M-Origin
your-access-key
Content-Type
application/json;ty=4
Accept
application/json
Body
As long as you send data, your monitor server application will get the data that the server gets. The data can be seen as follows.
Congratulations! You have just received a data notification.