Sample code for 30+ languages & platforms
DataFlex

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

DataFlex
Use ChilkatAx-win32.pkg

Procedure Test
    Boolean iSuccess
    Handle hoRest
    Boolean iBTls
    Integer iPort
    Boolean iBAutoReconnect
    String sResponseXml
    Handle hoXml
    String sTemp1
    Boolean bTemp1

    Move False To iSuccess

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

    Get Create (RefClass(cComChilkatRest)) To hoRest
    If (Not(IsComObjectCreated(hoRest))) Begin
        Send CreateComObject of hoRest
    End

    // 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).
    Move False To iBTls
    Move 80 To iPort
    Move True To iBAutoReconnect
    Get ComConnect Of hoRest "dev.markitondemand.com" iPort iBTls iBAutoReconnect To iSuccess

    // Get a stock quote:
    Get ComAddQueryParam Of hoRest "symbol" "AAPL" To iSuccess
    Get ComFullRequestNoBody Of hoRest "GET" "/MODApis/Api/v2/Quote" To sResponseXml
    Get ComLastMethodSuccess Of hoRest To bTemp1
    If (bTemp1 <> True) Begin
        Get ComLastErrorText Of hoRest To sTemp1
        Showln sTemp1
        Procedure_Return
    End

    Get Create (RefClass(cComChilkatXml)) To hoXml
    If (Not(IsComObjectCreated(hoXml))) Begin
        Send CreateComObject of hoXml
    End
    Get ComLoadXml Of hoXml sResponseXml To iSuccess
    Get ComGetChildContent Of hoXml "LastPrice" To sTemp1
    Showln "AAPL LastPrice: " sTemp1

    // Get another stock quote.  If a new HTTP connection is required,
    // the REST object will automatically connect using the same parameters.
    Get ComAddQueryParam Of hoRest "symbol" "AMZN" To iSuccess
    Get ComFullRequestNoBody Of hoRest "GET" "/MODApis/Api/v2/Quote" To sResponseXml
    Get ComLastMethodSuccess Of hoRest To bTemp1
    If (bTemp1 <> True) Begin
        Get ComLastErrorText Of hoRest To sTemp1
        Showln sTemp1
        Procedure_Return
    End

    Get ComLoadXml Of hoXml sResponseXml To iSuccess
    Get ComGetChildContent Of hoXml "LastPrice" To sTemp1
    Showln "AMZN LastPrice: " sTemp1


End_Procedure