Discover how a bimodal integration strategy can address the major data management challenges facing your organization today.
Get the Report →Automate Clio Integration Tasks from PowerShell
Are you in search of a quick and easy way to access Clio data from PowerShell? This article demonstrates how to utilize the Clio Cmdlets for tasks like connecting to Clio data, automating operations, downloading data, and more.
The CData API Driver for ADO.NET is a standard ADO.NET Provider that make it easy to accomplish data cleansing, normalization, backup, and other integration tasks by enabling real-time access to Clio.
ADO.NET Provider
The ADO.NET Provider provides a SQL interface for Clio; this tutorial shows how to use the Provider to retrieve Clio data.
Once you have acquired the necessary connection properties, accessing Clio data in PowerShell can be enabled in three steps.
Start by setting the Profile connection property to the location of the Clio Profile on disk (e.g. C:\profiles\Clio.apip). Next, set the ProfileSettings connection property to the connection string for Clio (see below).
Clio API Profile Settings
Clio uses OAuth-based authentication.
First, register an OAuth application with Clio. You can do so by logging to your Developer Account and clicking the Add button. Enter details and select the scope of your application here - these details will be shown to Clio users when they're asked to authorize your application. Your Oauth application will be assigned a client id (key) and a client secret (secret). Additionally you will need to set the Region in ProfileSettings connection property.
After setting the following connection properties, you are ready to connect:
- AuthScheme: Set this to OAuth.
- InitiateOAuth: Set this to GETANDREFRESH. You can use InitiateOAuth to manage the process to obtain the OAuthAccessToken.
- OAuthClientId: Set this to the client_id that is specified in you app settings.
- OAuthClientSecret: Set this to the client_secret that is specified in you app settings.
- CallbackURL: Set this to the Redirect URI that is specified in your app settings.
- Region: Set this in ProfileSettings to your Clio geographic region. Defaults to app.clio.com.
-
Load the provider's assembly:
[Reflection.Assembly]::LoadFile("C:\Program Files\CData\CData API Driver for ADO.NET\lib\System.Data.CData.API.dll")
-
Connect to Clio:
$conn= New-Object System.Data.CData.API.APIConnection("Profile=C:\profiles\Clio.apip;ProfileSettings='Region=your_region';Authscheme=OAuth;OAuthClientId=your_client_id;OAuthClientSecret=your_client_secret;CallbackUrl=your_callback_url;") $conn.Open()
-
Instantiate the APIDataAdapter, execute an SQL query, and output the results:
$sql="SELECT Id, Total from Bills" $da= New-Object System.Data.CData.API.APIDataAdapter($sql, $conn) $dt= New-Object System.Data.DataTable $da.Fill($dt) $dt.Rows | foreach { Write-Host $_.id $_.total }