Hi,
it seems I need another type of http authentification for getting JSON information from my gateway.
How I can realize such a request?
var http = require('http');
var auth = 'Basic ' + Buffer.from('username' + ':' + 'password').toString('base64');
var options = {
hostname: '192.168.x.y',
port: '8083',
path: '/mypath/devices',
method: 'GET',
headers: {'Authorization': auth},
json:true
}
var body='';
var callback = function(response) {
// Continuously update stream with data
response.on('data', function(data) {
body += data;
});
...
response.on('end', function() {
// Data received completely.
console.log(body);
process_data(); // here will be the main procedure
});
}
var req = http.request(options, callback);
req.end();
I have tried a simple request only with my name/password - it is not working, that’s why I think the auth method maybe wrong.
Thanks!