Xojo Plugin
Xojo Plugin
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 Xojo Plugin Downloads
Dim success As Boolean
success = False
Dim rest As New Chilkat.Rest
Dim bTls As Boolean
bTls = True
Dim bAutoReconnect As Boolean
bAutoReconnect = True
success = rest.Connect("example.com",443,bTls,bAutoReconnect)
If (success = False) Then
System.DebugLog(rest.LastErrorText)
Return
End If
// 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.
Dim sbRequest As New Chilkat.StringBuilder
success = sbRequest.Append("{ ""query"": ""chilkat"" }")
success = rest.AddHeader("Content-Type","application/json")
Dim sbResponse As New Chilkat.StringBuilder
success = rest.FullRequestSb("POST","/api/search",sbRequest,sbResponse)
If (success = False) Then
System.DebugLog(rest.LastErrorText)
Return
End If
Dim responseText As String
responseText = sbResponse.GetAsString()
If (sbResponse.LastMethodSuccess = False) Then
System.DebugLog(sbResponse.LastErrorText)
Return
End If
System.DebugLog(responseText)