Xbase++
Xbase++
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 Xbase++ Downloads
LOCAL nSuccess
LOCAL oRest
LOCAL nBTls
LOCAL nBAutoReconnect
LOCAL oSbResponse
LOCAL cResponseText
nSuccess := 0
oRest := CreateObject("Chilkat.Rest")
nBTls := 1
nBAutoReconnect := 1
nSuccess := oRest:Connect("example.com", 443, nBTls, nBAutoReconnect)
IF (nSuccess == 0)
? oRest:LastErrorText
oRest:destroy()
RETURN
ENDIF
// FullRequestNoBodySb sends a request with no body and stores the text response body in a
// StringBuilder.
oSbResponse := CreateObject("Chilkat.StringBuilder")
nSuccess := oRest:FullRequestNoBodySb("GET", "/api/items/123", oSbResponse)
IF (nSuccess == 0)
? oRest:LastErrorText
oRest:destroy()
oSbResponse:destroy()
RETURN
ENDIF
cResponseText := oSbResponse:GetAsString()
IF (oSbResponse:LastMethodSuccess == 0)
? oSbResponse:LastErrorText
oRest:destroy()
oSbResponse:destroy()
RETURN
ENDIF
? cResponseText
oRest:destroy()
oSbResponse:destroy()