[SOLVED] Send data using nodeJS gets error

I am trying to update data using nodejs code

var req = require(‘request’);
var obj = { ‘humidity’: 100};

req ({
url : “http://things.ubidots.com/api/v1.6/devices/ESP8266/humidity/values?token=xxxxxxxxxxxxxxxx”,
method : “POST”,
headers : {
‘Content-Type’: ‘application/json’
},
json : true,
body : obj }, function( error, response, body) {
console.log( response);
});

And the return value : very long message but at the end

body: { detail: ‘Authentication credentials were not provided.’ }

Please help !

Okay, I found the solution.

var req = require(‘request’);
var obj = { ‘value’: 40}; // notice the key is ‘value’, not the variable name, in my case humidity

req ({
url : "http://things.ubidots.com/api/v1.6/devices/ESP8266/humidity/values?token=“your token value”,
method : “POST”,
headers : {
‘Content-Type’: ‘application/json’
},
json : true,
body : obj
}, function( error, response, body) {
console.log( body);
});

1 Like

Hi @nick_doi,

We are happy that you found the error :smiley: