Sample code for 30+ languages & platforms
Lianja

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 Lianja Downloads

Lianja
llSuccess = .F.

loRest = createobject("CkRest")
llBTls = .T.
llBAutoReconnect = .T.
llSuccess = loRest.Connect("example.com",443,llBTls,llBAutoReconnect)
if (llSuccess = .F.) then
    ? loRest.LastErrorText
    release loRest
    return
endif

//  FullRequestNoBodySb sends a request with no body and stores the text response body in a
//  StringBuilder.
loSbResponse = createobject("CkStringBuilder")
llSuccess = loRest.FullRequestNoBodySb("GET","/api/items/123",loSbResponse)
if (llSuccess = .F.) then
    ? loRest.LastErrorText
    release loRest
    release loSbResponse
    return
endif

lcResponseText = loSbResponse.GetAsString()
if (loSbResponse.LastMethodSuccess = .F.) then
    ? loSbResponse.LastErrorText
    release loRest
    release loSbResponse
    return
endif

? lcResponseText


release loRest
release loSbResponse