Created
March 3, 2017 20:26
-
-
Save gjyoung1974/3aba8236b456999dc6677cd1ef71a201 to your computer and use it in GitHub Desktop.
Query service now..
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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