Reputation: 135
I am trying to figure out how to actually post data using this node module: https://github.com/SamDecrock/node-http-ntlm
It looks like posting should be similar to: https://github.com/SamDecrock/node-httpreq#post
But the documentation for httpreq doesnt actually show POSTing a value, I only see parameters or how to POST an entire file. Im using node and have something along these lines:
NodeClient.prototype.create = function (xml) {
var options = {
url: this.url,
username: this.user,
password: this.pw,
domain: this.domain,
headers: {
'Content-type': 'text/plain'
}
};
return new Promise(function (resolve, reject) {
httpntlm.post(options,
function (err, resp) {
if(err) {
reject(err);
}
resolve(resp.body);
});
});
};
Obviously I never send my xml object, so I need to figure out how to include this. Reading the documentation hasnt lead me anywhere to this point.
Upvotes: 2
Views: 3898
Reputation: 6132
You can POST xml like this:
var httpntlm = require('httpntlm');
var xml = '<?xml version="1.0" encoding="UTF-8"?>'; // replace this with your xml
httpntlm.post({
url: "https://someurl.com",
username: 'm$',
password: 'stinks',
workstation: 'choose.something',
domain: '',
body: xml,
headers: { 'Content-Type': 'text/xml' }
}, function (err, res){
if(err) return err;
console.log(res.headers);
console.log(res.body);
});
Upvotes: 5
Reputation: 135
To add content to the post, you can include the following options:
Upvotes: 2