![]() |
Chilkat HOME Android™ AutoIt C C# C++ Chilkat2-Python CkPython Classic ASP DataFlex Delphi DLL Go Java Node.js Objective-C PHP Extension Perl PowerBuilder PowerShell PureBasic Ruby SQL Server Swift Tcl Unicode C Unicode C++ VB.NET VBScript Visual Basic 6.0 Visual FoxPro Xojo Plugin
(PureBasic) Send HTTPS POST with XML BodyDemonstrates how to send an HTTP (or HTTPS) POST where the body of the request is XML.
IncludeFile "CkHttpResponse.pb" IncludeFile "CkHttp.pb" Procedure ChilkatExample() ; This example requires the Chilkat API to have been previously unlocked. ; See Global Unlock Sample for sample code. http.i = CkHttp::ckCreate() If http.i = 0 Debug "Failed to create object." ProcedureReturn EndIf strXml.s = "<TransactionSetup xmlns=" + Chr(34) + "https://xyz.com" + Chr(34) + "><Credentials><AccountID>XXX</AccountID></Credentials></TransactionSetup>" ; Choose a content-type. Typical content types for XML POSTs are "application/xml" or "text/xml". CkHttp::ckSetRequestHeader(http,"Content-Type","text/xml") ; Maybe you need other headers? CkHttp::ckSetRequestHeader(http,"Accept","text/xml") resp.i = CkHttp::ckPostXml(http,"https://www.somewebsite.com/",strXml,"utf-8") If CkHttp::ckLastMethodSuccess(http) <> 1 Debug CkHttp::ckLastErrorText(http) CkHttp::ckDispose(http) ProcedureReturn EndIf ; Examine the response status code: Debug "response status code = " + Str(CkHttpResponse::ckStatusCode(resp)) ; Examine the response body: Debug "response body: " + CkHttpResponse::ckBodyStr(resp) CkHttpResponse::ckDispose(resp) CkHttp::ckDispose(http) ProcedureReturn EndProcedure |
© 2000-2025 Chilkat Software, Inc. All Rights Reserved.