Publish an Event with CoAP
To send an event to Wia, connect to the CoAP API and send a POST request to the URL coap://coap.wia.io/events.
To send an event to Wia, connect to the CoAP API and send a POST request to the URL coap://coap.wia.io/events.
// Install node coap client using `npm install node-coap-client`const coap = require("node-coap-client").CoapClient;// Create the buffer payload// Replace 'your-device-secret-key' with the secret key for your device// it should start with `d_sk`const bufferPayload = Buffer.from(JSON.stringify({ accessToken: 'your-device-secret-key', name: 'temperature', data: 21.5}));coap .request( 'coap://coap.wia.io:5683', 'post', bufferPayload ) .then(response => { console.log(response.payload.toString('utf-8')); }) .catch(err => { console.log(err); });We serve cookies on this site to analyse traffic and optimise your experience. By using the website you agree to the Privacy Policy.