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) HTTP POST x-www-form-urlencodedDemonstrates how to send a simple x-www-form-urlencoded POST.
integer li_rc oleobject loo_Http string ls_JsonStr oleobject loo_Req oleobject loo_Resp string ls_ResponseBody oleobject loo_Fac string ls_Filepath integer li_Success loo_Http = create oleobject li_rc = loo_Http.ConnectToNewObject("Chilkat_9_5_0.Http") if li_rc < 0 then destroy loo_Http MessageBox("Error","Connecting to COM object failed") return end if ls_JsonStr = "{ some json ... }" loo_Req = create oleobject li_rc = loo_Req.ConnectToNewObject("Chilkat_9_5_0.HttpRequest") // This query parameter just happens to be named "json" and contains JSON text. loo_Req.AddParam("json",ls_JsonStr) // We can optionally add more query parameters. loo_Req.AddParam("abc","123") loo_Req.AddParam("xml","<abc>123</abc>") // Note: Just because we passed a query param named "json" or "xml" means nothing special. It's still just // a name=value query parameter.. loo_Resp = loo_Http.PostUrlEncoded("http://example.net/cirrus/connect/report",loo_Req) if loo_Http.LastMethodSuccess <> 1 then Write-Debug loo_Http.LastErrorText destroy loo_Http destroy loo_Req return end if if loo_Resp.StatusCode <> 200 then Write-Debug "Hey, I didn't receive the expected response status code!" Write-Debug "status code = " + string(loo_Resp.StatusCode) end if // Could be error text if the status code wasn't what we expected, or could be the response // body you're seeking.. ls_ResponseBody = loo_Resp.BodyStr Write-Debug ls_ResponseBody loo_Fac = create oleobject li_rc = loo_Fac.ConnectToNewObject("Chilkat_9_5_0.FileAccess") ls_Filepath = "some file path" li_Success = loo_Fac.WriteEntireTextFile(ls_Filepath,ls_ResponseBody,"utf-8",0) if li_Success <> 1 then Write-Debug loo_Fac.LastErrorText end if destroy loo_Http destroy loo_Req destroy loo_Fac |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.