(JavaScript) Send HTTPS POST with XML Body
Demonstrates how to send an HTTP (or HTTPS) POST where the body of the request is XML.
var success = false;
// This example requires the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
var http = new CkHttp();
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 CkHttpResponse();
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);
|