![]() |
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
(DataFlex) TicketBAI -- Send HTTP POSTSee more TicketBAI ExamplesDemonstrates how to send a TicketBAI POST and get the response.Note: This example requires Chilkat v11.0.0 or greater.
Use ChilkatAx-win32.pkg Procedure Test Boolean iSuccess Handle hoHttp Variant vSbXml Handle hoSbXml Handle hoJson String sUrl Variant vResp Handle hoResp String sTemp1 Integer iTemp1 Move False To iSuccess // This example requires the Chilkat API to have been previously unlocked. // See Global Unlock Sample for sample code. Get Create (RefClass(cComChilkatHttp)) To hoHttp If (Not(IsComObjectCreated(hoHttp))) Begin Send CreateComObject of hoHttp End Get ComSetSslClientCertPfx Of hoHttp "your.pfx" "pfx_password" To iSuccess If (iSuccess = False) Begin Get ComLastErrorText Of hoHttp To sTemp1 Showln sTemp1 Procedure_Return End // Get the XML we wish to send in the body of the request. Get Create (RefClass(cComChilkatStringBuilder)) To hoSbXml If (Not(IsComObjectCreated(hoSbXml))) Begin Send CreateComObject of hoSbXml End Get ComLoadFile Of hoSbXml "qa_data/payload.xml" "utf-8" To iSuccess If (iSuccess = False) Begin Showln "Failed to load XML that is to be the HTTP request body" Procedure_Return End // Build the following JSON // { // "con": "LROE", // "apa": "1.1", // "inte": { // "nif": "número de identificación fiscal", // "nrs": "nombre o Razón social", // "ap1": "primer apellido", // "ap2": "segundo apellido" // }, // "drs": { // "mode": "140", // "ejer": "ejercicio" // } // } // Use this online tool to generate code from sample JSON: // Generate Code to Create JSON Get Create (RefClass(cComChilkatJsonObject)) To hoJson If (Not(IsComObjectCreated(hoJson))) Begin Send CreateComObject of hoJson End Get ComUpdateString Of hoJson "con" "LROE" To iSuccess Get ComUpdateString Of hoJson "apa" "1.1" To iSuccess Get ComUpdateString Of hoJson "inte.nif" "número de identificación fiscal" To iSuccess Get ComUpdateString Of hoJson "inte.nrs" "nombre o Razón social" To iSuccess Get ComUpdateString Of hoJson "inte.ap1" "primer apellido" To iSuccess Get ComUpdateString Of hoJson "inte.ap2" "segundo apellido" To iSuccess Get ComUpdateString Of hoJson "drs.mode" "140" To iSuccess Get ComUpdateString Of hoJson "drs.ejer" "ejercicio" To iSuccess // Add required headers... Send ComSetRequestHeader To hoHttp "eus-bizkaia-n3-version" "1.0" Send ComSetRequestHeader To hoHttp "eus-bizkaia-n3-content-type" "application/xml" Get ComEmit Of hoJson To sTemp1 Send ComSetRequestHeader To hoHttp "eus-bizkaia-n3-data" sTemp1 Move "https://pruesarrerak.bizkaia.eus/N3B4000M/aurkezpena" To sUrl Get Create (RefClass(cComChilkatHttpResponse)) To hoResp If (Not(IsComObjectCreated(hoResp))) Begin Send CreateComObject of hoResp End Set ComUncommonOptions Of hoHttp To "SendGzipped" Get pvComObject of hoSbXml to vSbXml Get pvComObject of hoResp to vResp Get ComHttpSb Of hoHttp "POST" sUrl vSbXml "utf-8" "application/octet-stream" vResp To iSuccess If (iSuccess = False) Begin Get ComLastErrorText Of hoHttp To sTemp1 Showln sTemp1 Procedure_Return End Send ComClearHeaders To hoHttp Get ComStatusCode Of hoResp To iTemp1 Showln "response status code: " iTemp1 // Examine the response (it is already decompressed) Showln "response body:" Get ComBodyStr Of hoResp To sTemp1 Showln sTemp1 End_Procedure |
© 2000-2025 Chilkat Software, Inc. All Rights Reserved.