Device.insert - Do I need an authorization? Isn't the device token enough to authorize?


I have an external analysis attached to a device and in it I want to insert data to another device. I run the following NodeJS code:

.then((result) => {
console.log(‘Inseriu dados corretamente!’, result);
.catch((error) => {
console.log(‘Erro ao inserir dados:’, error);

where deviceComPressaoMedia is

Device {
token: Device {
token: ’ 0c8xxxxxxxx134’,
default_options: { json: true, headers: [Object] }*
default_options: {
json: true,
headers: { Token: [Device], ‘User-Agent’: ‘TagoIO-SDKJS-9.2.0’ }

and dadosParaEnviarBucket is

[{“variable”:“pressaomedia”,“unit”:“mca”,“value”:“17.4”,“time”:“2020-03-15 23:39:57”},{“variable”:“situacaopressao”,“unit”:“situacao”,“value”:“BAIXA”,“time”:“2020-03-15 23:39:57”}]

I created a new Custon Https device with the name 001-pressaoMedia and token 0c8xxxxxxxx134 to receive this data.

The point is. In the external NodeJS application I receive the following error when i run the deviceComPressaoMedia.insert statement:

Erro ao inserir dados: {
url: ‘’,
method: ‘POST’,
status: 401,
code: ‘UNKNOWN’,
statusText: 'Unauthorized’

It says I am not authorized. Do I need an authorization? Isn’t the device token enough to authorize?

Hi @jmpinheiro,

Are you using the SDK to send your data?
If you are using, could you check if it’s updated with the last version?
You can run npm outdated to check your npm package version.
I’m attaching the SDK documentation on posting data to TagoIO.
Node.js | Device | .insert

I updated, but the problem continued. I solved, I saw an example at the node_modules (tago-!examples-device.js) and I realize I sent, to the device bucket, the data as a JSON string not a JavaScript Array. Just changed that and it worked.

Another problem was the token, that was registered twice, one over the other.


1 Like