Skip to content

Instantly share code, notes, and snippets.

@gjyoung1974
Created March 3, 2017 20:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gjyoung1974/3aba8236b456999dc6677cd1ef71a201 to your computer and use it in GitHub Desktop.
Save gjyoung1974/3aba8236b456999dc6677cd1ef71a201 to your computer and use it in GitHub Desktop.
Query service now..
// 2017 gjyoung1974@gmail.com
// A script to query service now
process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0"; //ignore the issuer certificate !!NEVER DO THIS IN PROD!!!
var https = require('https');
// set up our options
var options = {
host: 'someplace.service-now.com',
port: 443,
path:'/api/now/table/sc_request',
headers: { // digest authentication over HTTPS
'Authorization': 'Basic ' + new Buffer("SomeUser" + ':' + "SomePassword").toString('base64')
}
};
//Call the rest endpoint
request = https.get(options, function(res){
var body = "";
res.on('data', function(data) {
body += data;
});
res.on('end', function() {
//here we have the full response, html or json object
console.log(body);
})
res.on('error', function(e) {
console.log("Got error: " + e.message);
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment