Sample code for 30+ languages & platforms
Visual Basic 6.0

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 Visual Basic 6.0 Downloads

Visual Basic 6.0
Dim success As Long
success = 0

Dim rest As New ChilkatRest
Dim bTls As Long
bTls = 1
Dim bAutoReconnect As Long
bAutoReconnect = 1
success = rest.Connect("example.com",443,bTls,bAutoReconnect)
If (success = 0) Then
    Debug.Print 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 ChilkatStringBuilder
success = sbRequest.Append("{ ""query"": ""chilkat"" }")

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

Dim sbResponse As New ChilkatStringBuilder
success = rest.FullRequestSb("POST","/api/search",sbRequest,sbResponse)
If (success = 0) Then
    Debug.Print rest.LastErrorText
    Exit Sub
End If

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

Debug.Print responseText