Chilkat Examples

ChilkatHOMEAndroid™Classic ASPCC++C#Mono C#.NET Core C#C# UWP/WinRTDataFlexDelphi ActiveXDelphi DLLVisual FoxProJavaLianjaMFCObjective-CPerlPHP ActiveXPHP ExtensionPowerBuilderPowerShellPureBasicCkPythonChilkat2-PythonRubySQL ServerSwift 2Swift 3/4TclUnicode CUnicode C++Visual Basic 6.0VB.NETVB.NET UWP/WinRTVBScriptXojo PluginNode.jsExcelGo

DataFlex Web API Examples

Primary Categories

AWS Translate
Activix CRM
Adyen
Amazon MWS
Azure Maps
Azure Monitor
Azure OAuth2
Azure Storage Accounts
Bluzone
CardConnect
ClickBank
Clickatell
Cloudfare
DocuSign
ETrade
Etsy
Facebook
GeoOp
GetHarvest
Jira
MYOB

Magento
Microsoft Calendar
Microsoft Group
Microsoft Tasks and Plans
Okta OAuth/OIDC
OneLogin OIDC
PayPal
Peoplevox
Populi
QuickBooks
SOAP finkok.com
Shippo
Shopify
Stripe
SugarCRM
Trello
Twitter
VoiceBase
Vonage
Walmart
Walmart v3
Xero
eBay
effectconnect

 

 

 

(DataFlex) Xero Get Folders (Files API)

Demonstrates how to retrieve the list of folders.

Note: This example requires Chilkat v9.5.0.64 or greater.

Chilkat ActiveX Downloads

ActiveX for 32-bit and 64-bit Windows

Use ChilkatAx-9.5.0-win32.pkg

Procedure Test
    Handle hoRest
    Boolean iSuccess
    Variant vSbJson
    Handle hoSbJson
    Handle hoJsonArr
    Integer i
    Integer iNumFolders
    Variant vJson
    Handle hoJson
    String sTemp1
    Integer iTemp1
    Boolean bTemp1

    // Note: Requires Chilkat v9.5.0.64 or greater.

    // This 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

    // Before sending REST API calls, the REST object needs to be
    // initialized for OAuth1.
    // See Xero 2-Legged OAuth1 Setup for sample code.

    // Assuming the REST object's OAuth1 authenticator is setup, and the initial
    // connection was made, we may now send REST HTTP requests..

    // Get the full list of folders (in the FILES API)
    Get Create (RefClass(cComChilkatStringBuilder)) To hoSbJson
    If (Not(IsComObjectCreated(hoSbJson))) Begin
        Send CreateComObject of hoSbJson
    End
    Get pvComObject of hoSbJson to vSbJson
    Get ComFullRequestNoBodySb Of hoRest "GET" "/files.xro/1.0/Folders" vSbJson To iSuccess
    If (iSuccess <> True) Begin
        Get ComLastErrorText Of hoRest To sTemp1
        Showln sTemp1
        Procedure_Return
    End

    // The response is a JSON array.
    Get Create (RefClass(cComChilkatJsonArray)) To hoJsonArr
    If (Not(IsComObjectCreated(hoJsonArr))) Begin
        Send CreateComObject of hoJsonArr
    End
    Get pvComObject of hoSbJson to vSbJson
    Get ComLoadSb Of hoJsonArr vSbJson To iSuccess
    Set ComEmitCompact Of hoJsonArr To False

    // A 200 response is expected for actual success.
    Get ComResponseStatusCode Of hoRest To iTemp1
    If (iTemp1 <> 200) Begin
        Get ComEmit Of hoJsonArr To sTemp1
        Showln sTemp1
        Procedure_Return
    End

    Get ComEmit Of hoJsonArr To sTemp1
    Showln sTemp1

    // The JSON list of folders looks like this:
    // See the code below showing how to iterate over the folders..

    // 	[
    // 	  { 
    // 	    "Name": "Inbox",
    // 	    "FileCount": 0,
    // 	    "Email": "xero.inbox.bt0xx.99ha3l7a28m7ghyn@xerofiles.com",
    // 	    "IsInbox": true,
    // 	    "Id": "de386667-2532-49d3-8ad8-b7727b128ea2"
    // 	  },
    // 	  { 
    // 	    "Name": "Contracts",
    // 	    "FileCount": 0,
    // 	    "IsInbox": false,
    // 	    "Id": "36f15a6e-74f3-42fd-8797-e288b9aae234"
    // 	  },
    // 	  { 
    // 	    "Name": "Images",
    // 	    "FileCount": 0,
    // 	    "IsInbox": false,
    // 	    "Id": "0ffca059-f2f1-4271-8de9-4b87c8c2c638"
    // 	  }
    // 	]

    Move 0 To i
    Get ComSize Of hoJsonArr To iNumFolders
    While (i < iNumFolders)
        Get ComObjectAt Of hoJsonArr i To vJson
        If (IsComObject(vJson)) Begin
            Get Create (RefClass(cComChilkatJsonObject)) To hoJson
            Set pvComObject Of hoJson To vJson
        End
        Get ComStringOf Of hoJson "Name" To sTemp1
        Showln "Name: " sTemp1
        Get ComIntOf Of hoJson "FileCount" To iTemp1
        Showln "FileCount: " iTemp1
        Get ComBoolOf Of hoJson "IsInbox" To bTemp1
        Showln "IsInbox: " bTemp1
        Get ComStringOf Of hoJson "Id" To sTemp1
        Showln "Id: " sTemp1
        Showln "--"
        Send Destroy of hoJson
        Move i + 1 To i
    Loop



End_Procedure

 

© 2000-2019 Chilkat Software, Inc. All Rights Reserved.