Skip to content

Instantly share code, notes, and snippets.

@Junch
Created May 25, 2015 06:55
Show Gist options
  • Select an option

  • Save Junch/371bc88e26f068eb2d21 to your computer and use it in GitHub Desktop.

Select an option

Save Junch/371bc88e26f068eb2d21 to your computer and use it in GitHub Desktop.
Post a message from Nodejs
// https://nodejs.org/api/http.html#http_http
var http=require('http');
var querystring=require('querystring');
var postData = querystring.stringify({
connection_string: "User Id=xxxx;Password=xxxxxx;Data Source=ussclpecergp-scan.autodesk.com/CERPRD.autodesk.com"
});
var options = {
hostname: 'cerreport.autodesk.com',
port: 8080,
path: '/OracleDbAccount',
method: 'POST',
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
'Content-Length': postData.length
}
};
var req = http.request(options, function(res) {
console.log('STATUS: ' + res.statusCode);
console.log('HEADERS: ' + JSON.stringify(res.headers));
res.setEncoding('utf8');
res.on('data', function (chunk) {
console.log('BODY: ' + chunk);
});
});
req.on('error', function(e) {
console.log('problem with request: ' + e.message);
});
// write data to request body
req.write(postData);
req.end();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment