I am trying to setup a simple node.js proxy to pass off a post to a web service (CSW in this isntance).
I'm posting XML in a request body, and specifying text/xml. -- The service requires these.
I get the raw xml text in the req.rawBody var and it works fine, I can't seem to resubmit it properly however.
My method looks like:
app.post('/csw*', function(req, res){
console.log("Making request to:" + geobusOptions.host + "With query params: " + req.rawBody);
request.post(
{url:'http://192.168.0.100/csw',
body : req.rawBody,
'Content-Type': 'text/xml'
},
function (error, response, body) {
if (!error && response.statusCode == 200) {
console.log(body)
}
}
);
});
I just want to submit a string in a POST, using content-type text/xml. I can't seem to accomplish this however!
I am using the 'request' library @ https://github.com/mikeal/request
Edit -- Whoops! I forgot to just add the headers...
This works great:
request.post(
{url:'http://192.168.0.100/csw',
body : req.rawBody,
headers: {'Content-Type': 'text/xml'}
},
function (error, response, body) {
if (!error && response.statusCode == 200) {
console.log(body)
}
}
);