I am trying to call a https web service from node.js. I am behind a proxy, so i am providing the proxy and port in the options along with the credentials. But i am getting the following error
[Error: 2060:error:140770FC:SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol
:openssl\ssl\s23_clnt.c:683:
]
The following is the code snippet in which i am trying to call the https web service:
var https = require('https');
var username = 'username';
var password = 'password';
var auth = 'Basic ' + new Buffer(username + ':' + password).toString('base64');
var data = '';
var options = {
hostname: 'proxy',
port: 8080,
path: 'https://crm.zoho.com/crm/private/json/Leads/getMyRecords?authtoken=11111tsvs26677026bcba45ae3f&scope=crmapi',
headers: {
"Proxy-Authorization" : auth
}
};
console.log("options- " + JSON.stringify(options) + '\n');
var req = https.request(options, function(res) {
console.log("statusCode- " + res.statusCode);
console.log("headers-" + res.headers);
res.on('data', function(chunk) {
data += chunk;
});
res.on('end', function (chunk) {
console.log('response-' + data);
});
});
req.end();
req.on('error', function(e) {
console.error(e);
});
Can anyone please help me resolve this issue?
Thanks in advance, Manoj
I had the same problem by mistake using
But my proxy requires HTTP only, the proxy will in charge to complete the request HTTPS because you are setting it on path parameter
This works for me:
Ouput:
Kind Regards