![]() |
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) Transition from Http.PostJson3 to Http.HttpJsonProvides instructions for replacing deprecated PostJson3 method calls with HttpJson. Note: This example requires Chilkat v11.0.0 or greater.
IncludeFile "CkHttpResponse.pb" IncludeFile "CkHttp.pb" IncludeFile "CkJsonObject.pb" Procedure ChilkatExample() http.i = CkHttp::ckCreate() If http.i = 0 Debug "Failed to create object." ProcedureReturn EndIf url.s = "https://example.com/something" contentType.s = "application/json" json.i = CkJsonObject::ckCreate() If json.i = 0 Debug "Failed to create object." ProcedureReturn EndIf CkJsonObject::ckLoadFile(json,"C:/temp/requestBody.json") ; ------------------------------------------------------------------------ ; The PostJson3 method is deprecated: responseObj.i = CkHttp::ckPostJson3(http,url,contentType,json) If CkHttp::ckLastMethodSuccess(http) = 0 Debug CkHttp::ckLastErrorText(http) CkHttp::ckDispose(http) CkJsonObject::ckDispose(json) ProcedureReturn EndIf ; ... ; ... CkHttpResponse::ckDispose(responseObj) ; ------------------------------------------------------------------------ ; Do the equivalent using HttpJson. ; Your application creates a new, empty HttpResponse object which is passed ; in the last argument and filled upon success. responseOut.i = CkHttpResponse::ckCreate() If responseOut.i = 0 Debug "Failed to create object." ProcedureReturn EndIf success.i = CkHttp::ckHttpJson(http,"POST",url,json,contentType,responseOut) If success = 0 Debug CkHttp::ckLastErrorText(http) CkHttp::ckDispose(http) CkJsonObject::ckDispose(json) CkHttpResponse::ckDispose(responseOut) ProcedureReturn EndIf CkHttp::ckDispose(http) CkJsonObject::ckDispose(json) CkHttpResponse::ckDispose(responseOut) ProcedureReturn EndProcedure |
© 2000-2025 Chilkat Software, Inc. All Rights Reserved.