Sample code for 30+ languages & platforms
PowerBuilder

REST Auto Reconnect for Multiple Requests (dev.markitondemand.com)

See more REST Examples

Demonstrates how the autoReconnect argument to the Connect method is used.

Chilkat PowerBuilder Downloads

PowerBuilder
integer li_rc
integer li_Success
oleobject loo_Rest
integer li_BTls
integer li_Port
integer li_BAutoReconnect
string ls_ResponseXml
oleobject loo_Xml

li_Success = 0

// This example requires the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.

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

// This example demonstrates the usage of the autoReconnect argument to the Connect method.
// When autoReconnect is on, subsequent REST method calls will automatically re-connect
// if necessary, using the same information (domain/IP address, port number, and TLS).
li_BTls = 0
li_Port = 80
li_BAutoReconnect = 1
li_Success = loo_Rest.Connect("dev.markitondemand.com",li_Port,li_BTls,li_BAutoReconnect)

// Get a stock quote:
li_Success = loo_Rest.AddQueryParam("symbol","AAPL")
ls_ResponseXml = loo_Rest.FullRequestNoBody("GET","/MODApis/Api/v2/Quote")
if loo_Rest.LastMethodSuccess <> 1 then
    Write-Debug loo_Rest.LastErrorText
    destroy loo_Rest
    return
end if

loo_Xml = create oleobject
li_rc = loo_Xml.ConnectToNewObject("Chilkat.Xml")

li_Success = loo_Xml.LoadXml(ls_ResponseXml)
Write-Debug "AAPL LastPrice: " + loo_Xml.GetChildContent("LastPrice")

// Get another stock quote.  If a new HTTP connection is required,
// the REST object will automatically connect using the same parameters.
li_Success = loo_Rest.AddQueryParam("symbol","AMZN")
ls_ResponseXml = loo_Rest.FullRequestNoBody("GET","/MODApis/Api/v2/Quote")
if loo_Rest.LastMethodSuccess <> 1 then
    Write-Debug loo_Rest.LastErrorText
    destroy loo_Rest
    destroy loo_Xml
    return
end if

li_Success = loo_Xml.LoadXml(ls_ResponseXml)
Write-Debug "AMZN LastPrice: " + loo_Xml.GetChildContent("LastPrice")


destroy loo_Rest
destroy loo_Xml