I am trying to configure a simple node.js proxy to pass a message to a web service (CSW in this isntance).
I send the XML to the request body and specify text / xml. - Service requires them.
I get raw XML text in var.rawBody var and it works fine, but I cannot resend it.
My method looks like this:
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 send a string to POST using text like text / xml. I can't seem to do this!
I use the library 'request' @ https://github.com/mikeal/request
Change - Oops! 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)
}
}
);
source
share