Sample code for 30+ languages & platforms
VB.NET

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 VB.NET Downloads

VB.NET
Dim success As Boolean = False

Dim rest As New Chilkat.Rest
Dim bTls As Boolean = True
Dim bAutoReconnect As Boolean = True
success = rest.Connect("example.com",443,bTls,bAutoReconnect)
If (success = False) Then
    Debug.WriteLine(rest.LastErrorText)
    Exit Sub
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
sbRequest.Append("{ ""query"": ""chilkat"" }")

rest.AddHeader("Content-Type","application/json")

Dim sbResponse As New Chilkat.StringBuilder
success = rest.FullRequestSb("POST","/api/search",sbRequest,sbResponse)
If (success = False) Then
    Debug.WriteLine(rest.LastErrorText)
    Exit Sub
End If


Dim responseText As String = sbResponse.GetAsString()
If (sbResponse.LastMethodSuccess = False) Then
    Debug.WriteLine(sbResponse.LastErrorText)
    Exit Sub
End If

Debug.WriteLine(responseText)