Sample code for 30+ languages & platforms
Visual FoxPro

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 Visual FoxPro Downloads

Visual FoxPro
LOCAL lnSuccess
LOCAL loRest
LOCAL lnBTls
LOCAL lnBAutoReconnect
LOCAL loSbResponse
LOCAL lcResponseText

lnSuccess = 0

loRest = CreateObject('Chilkat.Rest')
lnBTls = 1
lnBAutoReconnect = 1
lnSuccess = loRest.Connect("example.com",443,lnBTls,lnBAutoReconnect)
IF (lnSuccess = 0) THEN
    ? loRest.LastErrorText
    RELEASE loRest
    CANCEL
ENDIF

*  FullRequestNoBodySb sends a request with no body and stores the text response body in a
*  StringBuilder.
loSbResponse = CreateObject('Chilkat.StringBuilder')
lnSuccess = loRest.FullRequestNoBodySb("GET","/api/items/123",loSbResponse)
IF (lnSuccess = 0) THEN
    ? loRest.LastErrorText
    RELEASE loRest
    RELEASE loSbResponse
    CANCEL
ENDIF

lcResponseText = loSbResponse.GetAsString()
IF (loSbResponse.LastMethodSuccess = 0) THEN
    ? loSbResponse.LastErrorText
    RELEASE loRest
    RELEASE loSbResponse
    CANCEL
ENDIF

? lcResponseText

RELEASE loRest
RELEASE loSbResponse