Sample code for 30+ languages & platforms
B4X

Send a Bodyless REST Request into a StringBuilder

See more REST Examples

Demonstrates Rest.FullRequestNoBodySb, which sends a request with no body and stores the text response body in a StringBuilder.

Background. This variant of the no-body full request writes the response into a StringBuilder rather than returning it as a string, which is convenient when the response will be further processed in place.

Chilkat B4X Downloads

B4X
Dim success As Boolean = False

Dim rest As ChilkatRest
rest.Initialize("rest")
Dim bTls As Boolean = True
Dim bAutoReconnect As Boolean = True
success = rest.Connect("example.com", 443, bTls, bAutoReconnect)
If success = False Then
    Log(rest.LastErrorText)
    Return
End If


'  FullRequestNoBodySb sends a request with no body and stores the text response body in a
'  StringBuilder.
Dim sbResponse As ChilkatStringBuilder
sbResponse.Initialize
success = rest.FullRequestNoBodySb("GET", "/api/items/123", sbResponse)
If success = False Then
    Log(rest.LastErrorText)
    Return
End If


Dim responseText As String = sbResponse.GetAsString
If sbResponse.LastMethodSuccess = False Then
    Log(sbResponse.LastErrorText)
    Return
End If

Log(responseText)