I'm getting an ECONNREFUSED error (shown below) when trying to make a POST request with the request module to my server's limesurvey remotecontrol API. Is there something I'm doing wrong? Code is below error.
Edit: fixed the space between the http: // now getting a new error.
New Error:
{"id":null,"result":null,"error":"unable to decode malformed json"}
Error:
{ [Error: connect ECONNREFUSED]
code: 'ECONNREFUSED',
errno: 'ECONNREFUSED',
syscall: 'connect' }
Code:
var options = {
"url": "http://localhost/limesurvey/index.php/admin/remotecontrol",
"headers": {
"Host": "dev-rheumpro.cis.uab.edu",
"Content-Type": "application/json",
"Connection": "Keep-Alive",
"Content-Length": "65",
"Port": "80",
"User-Agent": "request"
},
"body": '{ "method": "get_session_key", "params": { "username": "admin", "password":"password" },"id": 1}'
}
request.post("http: //localhost/limesurvey/index.php/admin/remotecontrol", options, function callback(error, response, body) {
if(!error && response.statusCode == 200){
console.log("testing");
}
else {
console.log(error);
}
});