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
(PureBasic) HttpPostJson2 ExampleDemonstrates use of the HttpPostJson2 method.
IncludeFile "CkHttpResponse.pb" IncludeFile "CkHttp.pb" IncludeFile "CkJsonObject.pb" Procedure ChilkatExample() ; This requires the Chilkat API to have been previously unlocked. ; See Global Unlock Sample for sample code ; See PostJson2Async Example for the async equivalent of this example. http.i = CkHttp::ckCreate() If http.i = 0 Debug "Failed to create object." ProcedureReturn EndIf success.i ; Sends a POST equivalent to the following CURL command: ; curl -X POST https://sandbox.plaid.com/institutions/get \ ; -H 'content-type: application/json' \ ; -d '{ ; "client_id": String, ; "secret":String, ; "count": Number, ; "offset": Number ; }' ; Suppress some default headers that would automatically added.. CkHttp::setCkAcceptCharset(http, "") CkHttp::setCkUserAgent(http, "") CkHttp::setCkAcceptLanguage(http, "") CkHttp::setCkAllowGzip(http, 0) jsonBody.s = "{" + Chr(34) + "client_id" + Chr(34) + ": " + Chr(34) + "PLAID_CLIENT_ID" + Chr(34) + ", " + Chr(34) + "secret" + Chr(34) + ":" + Chr(34) + "PLAID_SECRET" + Chr(34) + ", " + Chr(34) + "count" + Chr(34) + ": 10, " + Chr(34) + "offset" + Chr(34) + ": 0}" resp.i = CkHttp::ckPostJson2(http,"https://sandbox.plaid.com/institutions/get","application/json",jsonBody) If CkHttp::ckLastMethodSuccess(http) = 0 Debug CkHttp::ckLastErrorText(http) CkHttp::ckDispose(http) ProcedureReturn EndIf statusCode.i = CkHttpResponse::ckStatusCode(resp) Debug "Response status code = " + Str(statusCode) ; Examine the JSON response.. json.i = CkJsonObject::ckCreate() If json.i = 0 Debug "Failed to create object." ProcedureReturn EndIf CkJsonObject::ckLoad(json,CkHttpResponse::ckBodyStr(resp)) CkJsonObject::setCkEmitCompact(json, 0) Debug "JSON Response Body:" Debug CkJsonObject::ckEmit(json) CkHttpResponse::ckDispose(resp) CkHttp::ckDispose(http) CkJsonObject::ckDispose(json) ProcedureReturn EndProcedure |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.