Chilkat HOME .NET Core C# Android™ AutoIt C C# C++ Chilkat2-Python CkPython Classic ASP DataFlex Delphi ActiveX Delphi DLL Go Java Lianja Mono C# Node.js Objective-C PHP ActiveX PHP Extension Perl PowerBuilder PowerShell PureBasic Ruby SQL Server Swift 2 Swift 3,4,5... Tcl Unicode C Unicode C++ VB.NET VBScript Visual Basic 6.0 Visual FoxPro Xojo Plugin
(PowerBuilder) TicketBAI -- Send HTTP POSTSee more TicketBAI ExamplesDemonstrates how to send a TicketBAI POST and get the response.
integer li_rc oleobject loo_Http integer li_Success oleobject loo_SbXml oleobject loo_Json string ls_Url integer li_BGzip oleobject loo_Resp // This example requires the Chilkat API to have been previously unlocked. // See Global Unlock Sample for sample code. loo_Http = create oleobject // Use "Chilkat_9_5_0.Http" for versions of Chilkat < 10.0.0 li_rc = loo_Http.ConnectToNewObject("Chilkat.Http") if li_rc < 0 then destroy loo_Http MessageBox("Error","Connecting to COM object failed") return end if li_Success = loo_Http.SetSslClientCertPfx("your.pfx","pfx_password") if li_Success = 0 then Write-Debug loo_Http.LastErrorText destroy loo_Http return end if // Get the XML we wish to send in the body of the request. loo_SbXml = create oleobject // Use "Chilkat_9_5_0.StringBuilder" for versions of Chilkat < 10.0.0 li_rc = loo_SbXml.ConnectToNewObject("Chilkat.StringBuilder") li_Success = loo_SbXml.LoadFile("qa_data/payload.xml","utf-8") if li_Success = 0 then Write-Debug "Failed to load XML that is to be the HTTP request body" destroy loo_Http destroy loo_SbXml return end if // 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 loo_Json = create oleobject // Use "Chilkat_9_5_0.JsonObject" for versions of Chilkat < 10.0.0 li_rc = loo_Json.ConnectToNewObject("Chilkat.JsonObject") loo_Json.UpdateString("con","LROE") loo_Json.UpdateString("apa","1.1") loo_Json.UpdateString("inte.nif","número de identificación fiscal") loo_Json.UpdateString("inte.nrs","nombre o Razón social") loo_Json.UpdateString("inte.ap1","primer apellido") loo_Json.UpdateString("inte.ap2","segundo apellido") loo_Json.UpdateString("drs.mode","140") loo_Json.UpdateString("drs.ejer","ejercicio") // Add required headers... loo_Http.SetRequestHeader("eus-bizkaia-n3-version","1.0") loo_Http.SetRequestHeader("eus-bizkaia-n3-content-type","application/xml") loo_Http.SetRequestHeader("eus-bizkaia-n3-data",loo_Json.Emit()) ls_Url = "https://pruesarrerak.bizkaia.eus/N3B4000M/aurkezpena" li_BGzip = 1 loo_Resp = loo_Http.PTextSb("POST",ls_Url,loo_SbXml,"utf-8","application/octet-stream",0,li_BGzip) if loo_Http.LastMethodSuccess = 0 then Write-Debug loo_Http.LastErrorText destroy loo_Http destroy loo_SbXml destroy loo_Json return end if loo_Http.ClearHeaders() Write-Debug "response status code: " + string(loo_Resp.StatusCode) // Examine the response (it is already decompressed) Write-Debug "response body:" Write-Debug loo_Resp.BodyStr destroy loo_Resp destroy loo_Http destroy loo_SbXml destroy loo_Json |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.