var https = require('https'); var p = '/api/username/FA/AA?ZOHO_ACTION=EXPORT&ZOHO_OUTPUT_FORMAT=JSON&ZOHO_ERROR_FORMAT=JSON&ZOHO_API_KEY=dummy1234&ticket=dummy9876&ZOHO_API_VERSION=1.0'; var https = require('https'); var options = { host: 'reportsapi.zoho.com', port: 443, path: p, method: 'POST' }; var req = https.request(options, function(res) { console.log("statusCode: ", res.statusCode); console.log("headers: ", res.headers); res.on('data', function(d) { process.stdout.write(d); }); }); req.end(); req.on('error', function(e) { console.error(e); });
When I run the above code, I get below the error.
error message:
statusCode: 411 headers: { 'content-type': 'text/html', 'content-length': '357', connection: 'close', date: 'Thu, 24 Nov 2011 19:58:51 GMT', server: 'ZGS', 'strict-transport-security': 'max-age=604800' } "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 411 - Length Required
How to fix abobe error?
I tried to do below
var qs = 'ZOHO_ACTION=EXPORT&ZOHO_OUTPUT_FORMAT=JSON&ZOHO_ERROR_FORMAT=JSON&ZOHO_API_KEY=dummy1234&ticket=dummy9876&ZOHO_API_VERSION=1.0'; ' options.headers = {'Content-Length': qs.length}
But if I try this way, I get below error:
{ stack: [Getter/Setter], arguments: undefined, type: undefined, message: 'socket hang up' }
Can someone help me with this?
thanks
koti
PS: If I enter the entire URL into the address bar of the browser and press enter, I get a JSON response as expected.
ekanna
source share