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

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

@José Maria Villac Pinheiro

Hi!

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:

deviceComPressaoMedia.insert(dadosParaEnviarBucket)
.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: {
from: ‘SERVER_RESPONSE’,
url: ‘https://api.tago.io/data’,
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?