Node.js
Node.js
Send HTTPS POST with XML Body
See more HTTP Examples
Demonstrates how to send an HTTP (or HTTPS) POST where the body of the request is XML.Chilkat Node.js Downloads
NODEJS_PRELUDE
function chilkatExample() {
var success = false;
// This example requires the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
var http = new chilkat.Http();
var strXml = "<TransactionSetup xmlns=\"https://xyz.com\"><Credentials><AccountID>XXX</AccountID></Credentials></TransactionSetup>";
// Maybe you need other headers?
http.SetRequestHeader("Accept","application/xml");
var resp = new chilkat.HttpResponse();
success = http.HttpStr("POST","https://www.somewebsite.com/",strXml,"utf-8","application/xml",resp);
if (success == false) {
console.log(http.LastErrorText);
return;
}
// Examine the response status code:
console.log("response status code = " + resp.StatusCode);
// Examine the response body:
console.log("response body: " + resp.BodyStr);
}
chilkatExample();