AutoIt
AutoIt
Send a REST Request using StringBuilder Bodies
See more REST Examples
Demonstrates Rest.FullRequestSb, which sends a complete request whose text body is read from a StringBuilder and stores the text response body in a second StringBuilder.
Background. Using StringBuilder objects for the request and response bodies avoids extra string conversions, which is helpful when working with large payloads.
Chilkat AutoIt Downloads
Local $bSuccess = False
$oRest = ObjCreate("Chilkat.Rest")
Local $bTls = True
Local $bAutoReconnect = True
$bSuccess = $oRest.Connect("example.com",443,$bTls,$bAutoReconnect)
If ($bSuccess = False) Then
ConsoleWrite($oRest.LastErrorText & @CRLF)
Exit
EndIf
; FullRequestSb sends a request whose text body is read from a StringBuilder and stores the text
; response body in a second StringBuilder. This avoids extra string conversions for large bodies.
$oSbRequest = ObjCreate("Chilkat.StringBuilder")
$oSbRequest.Append("{ ""query"": ""chilkat"" }")
$oRest.AddHeader("Content-Type","application/json")
$oSbResponse = ObjCreate("Chilkat.StringBuilder")
$bSuccess = $oRest.FullRequestSb("POST","/api/search",$oSbRequest,$oSbResponse)
If ($bSuccess = False) Then
ConsoleWrite($oRest.LastErrorText & @CRLF)
Exit
EndIf
Local $sResponseText = $oSbResponse.GetAsString()
If ($oSbResponse.LastMethodSuccess = False) Then
ConsoleWrite($oSbResponse.LastErrorText & @CRLF)
Exit
EndIf
ConsoleWrite($sResponseText & @CRLF)