Sample code for 30+ languages & platforms
PowerBuilder

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

PowerBuilder
integer li_rc
integer li_Success
oleobject loo_Rest
integer li_BTls
integer li_BAutoReconnect
oleobject loo_SbResponse
string ls_ResponseText

li_Success = 0

loo_Rest = create oleobject
li_rc = loo_Rest.ConnectToNewObject("Chilkat.Rest")
if li_rc < 0 then
    destroy loo_Rest
    MessageBox("Error","Connecting to COM object failed")
    return
end if
li_BTls = 1
li_BAutoReconnect = 1
li_Success = loo_Rest.Connect("example.com",443,li_BTls,li_BAutoReconnect)
if li_Success = 0 then
    Write-Debug loo_Rest.LastErrorText
    destroy loo_Rest
    return
end if

//  FullRequestNoBodySb sends a request with no body and stores the text response body in a
//  StringBuilder.
loo_SbResponse = create oleobject
li_rc = loo_SbResponse.ConnectToNewObject("Chilkat.StringBuilder")

li_Success = loo_Rest.FullRequestNoBodySb("GET","/api/items/123",loo_SbResponse)
if li_Success = 0 then
    Write-Debug loo_Rest.LastErrorText
    destroy loo_Rest
    destroy loo_SbResponse
    return
end if

ls_ResponseText = loo_SbResponse.GetAsString()
if loo_SbResponse.LastMethodSuccess = 0 then
    Write-Debug loo_SbResponse.LastErrorText
    destroy loo_Rest
    destroy loo_SbResponse
    return
end if

Write-Debug ls_ResponseText


destroy loo_Rest
destroy loo_SbResponse