Hi community,
I have an issue with uploading the file using API to GenieACS.
I got the following error code when I running the code:
PS C:\Users\nzhang\testingCode> node .\savetxt.js
problem with request: getaddrinfo ENOTFOUND http://10.228.228.3
PS C:\Users\nzhang\testingCode>
Suspect it is a network issue:
PS C:\Users\nzhang\testingCode> Test-NetConnection 10.228.228.3 -p 80
WARNING: TCP connect to (10.228.228.3 : 80) failed
ComputerName : 10.228.228.3
RemoteAddress : 10.228.228.3
RemotePort : 80
InterfaceAlias : VirtualBox Host-Only Network #3
SourceAddress : 10.228.228.254
PingSucceeded : True
PingReplyDetails (RTT) : 0 ms
TcpTestSucceeded : False
My code is in below:
const http = require(‘http’);
const options = {
hostname: ‘http://10.228.228.3’,
port: 3000,
path: ‘/files’,
method: ‘PUT’,
headers: {
‘fileType’: ‘3 Vendor Configuration File’,
‘oui’: ‘70FC8C’,
‘productClass’: ‘MB425SAV2ad0UFPE4BuNW’,
‘version’: ‘2.0’,
}
};
const req = http.request(options, (res) => {
console.log(STATUS: ${res.statusCode}
);
console.log(HEADERS: ${JSON.stringify(res.headers)}
);
res.setEncoding(‘utf8’);
res.on(‘data’, (chunk) => {
console.log(BODY: ${chunk}
);
});
res.on(‘end’, () => {
console.log(‘No more data in response.’);
});
});
req.on(‘error’, (e) => {
console.error(problem with request: ${e.message}
);
});
// Write data to request body
req.write(template);
req.end();