Skip to content

Instantly share code, notes, and snippets.

@dandye
Last active March 25, 2016 21:45
Show Gist options
  • Save dandye/a4bb984e31a328382a66 to your computer and use it in GitHub Desktop.
Save dandye/a4bb984e31a328382a66 to your computer and use it in GitHub Desktop.
Create an Edge user with node.js
const https = require('https');
var querystring = require('querystring');
//FixMe; this is INSECURE!
process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0";
var payload = querystring.stringify({
"username": "dandye",
"password": "redacted",
"first_name": "Dan",
"last_name": "Dye",
"email": "[email protected]"
});
var options = {
hostname:'198.61.196.224',
port: 443,
path: '/api/users/',
method: 'POST',
auth: 'admin:redacted',
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
'Content-Length': payload.length
}
};
var req = https.request(options, (res) => {
console.log('statusCode: ', res.statusCode);
res.setEncoding('utf8');
res.on('data', (d) => {
process.stdout.write(d);
});
});
req.on('error', (e) => {
console.error(e);
});
req.write(payload);
req.end();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment