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
(DataFlex) POST application/x-www-form-urlencoded using REST APIDemonstrates how to send a POST with query params (x-www-form-urlencoded) using the Chilkat REST object.
Use ChilkatAx-win32.pkg Procedure Test Handle hoRest Boolean iBTls Integer iPort Boolean iBAutoReconnect Boolean iSuccess String sResponseStr String sTemp1 Integer iTemp1 Boolean bTemp1 // This example requires the Chilkat API to have been previously unlocked. // See Global Unlock Sample for sample code. Get Create (RefClass(cComChilkatRest)) To hoRest If (Not(IsComObjectCreated(hoRest))) Begin Send CreateComObject of hoRest End // This example will send to https://www.chilkatsoft.com/echoPost.asp // Make the initial connection (without sending a request yet). Move True To iBTls Move 443 To iPort Move True To iBAutoReconnect Get ComConnect Of hoRest "www.chilkatsoft.com" iPort iBTls iBAutoReconnect To iSuccess If (iSuccess <> True) Begin Get ComLastErrorText Of hoRest To sTemp1 Showln sTemp1 Procedure_Return End // Provide query params. Get ComAddQueryParam Of hoRest "firstName" "John" To iSuccess Get ComAddQueryParam Of hoRest "lastName" "Doe" To iSuccess Get ComAddQueryParam Of hoRest "company" "Bisco Bits Ltd." To iSuccess Get ComFullRequestFormUrlEncoded Of hoRest "POST" "/echoPost.asp" To sResponseStr Get ComLastMethodSuccess Of hoRest To bTemp1 If (bTemp1 <> True) Begin Get ComLastErrorText Of hoRest To sTemp1 Showln sTemp1 Procedure_Return End // When successful, the response status code will equal 200. Get ComResponseStatusCode Of hoRest To iTemp1 If (iTemp1 <> 200) Begin // Examine the request/response to see what happened. Get ComResponseStatusCode Of hoRest To iTemp1 Showln "response status code = " iTemp1 Get ComResponseStatusText Of hoRest To sTemp1 Showln "response status text = " sTemp1 Get ComResponseHeader Of hoRest To sTemp1 Showln "response header: " sTemp1 Showln "response body (if any): " sResponseStr Showln "---" Get ComLastRequestStartLine Of hoRest To sTemp1 Showln "LastRequestStartLine: " sTemp1 Get ComLastRequestHeader Of hoRest To sTemp1 Showln "LastRequestHeader: " sTemp1 Procedure_Return End Showln sResponseStr Showln "Success." End_Procedure |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.