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
(Unicode C++) TicketBAI -- Send HTTP POSTSee more TicketBAI ExamplesDemonstrates how to send a TicketBAI POST and get the response.
#include <CkHttpW.h> #include <CkStringBuilderW.h> #include <CkJsonObjectW.h> #include <CkHttpResponseW.h> void ChilkatSample(void) { // This example requires the Chilkat API to have been previously unlocked. // See Global Unlock Sample for sample code. CkHttpW http; bool success = http.SetSslClientCertPfx(L"your.pfx",L"pfx_password"); if (success == false) { wprintf(L"%s\n",http.lastErrorText()); return; } // Get the XML we wish to send in the body of the request. CkStringBuilderW sbXml; success = sbXml.LoadFile(L"qa_data/payload.xml",L"utf-8"); if (success == false) { wprintf(L"Failed to load XML that is to be the HTTP request body\n"); return; } // 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/240", // "ejer": "ejercicio" // } // } // Use this online tool to generate code from sample JSON: // Generate Code to Create JSON CkJsonObjectW json; json.UpdateString(L"con",L"LROE"); json.UpdateString(L"apa",L"1.1"); json.UpdateString(L"inte.nif",L"número de identificación fiscal"); json.UpdateString(L"inte.nrs",L"nombre o Razón social"); json.UpdateString(L"inte.ap1",L"primer apellido"); json.UpdateString(L"inte.ap2",L"segundo apellido"); json.UpdateString(L"drs.mode",L"140/240"); json.UpdateString(L"drs.ejer",L"ejercicio"); // Add required headers... http.SetRequestHeader(L"eus-bizkaia-n3-version",L"1.0"); http.SetRequestHeader(L"eus-bizkaia-n3-content-type",L"application/xml"); http.SetRequestHeader(L"eus-bizkaia-n3-data",json.emit()); const wchar_t *url = L"https://pruesarrerak.bizkaia.eus/N3B4000M/aurkezpena"; bool bGzip = true; CkHttpResponseW *resp = http.PTextSb(L"POST",url,sbXml,L"utf-8",L"application/octet-stream",false,bGzip); if (http.get_LastMethodSuccess() == false) { wprintf(L"%s\n",http.lastErrorText()); return; } http.ClearHeaders(); wprintf(L"response status code: %d\n",resp->get_StatusCode()); // Examine the response (it is already decompressed) wprintf(L"response body:\n"); wprintf(L"%s\n",resp->bodyStr()); delete resp; } |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.