Automate Asana Integration Tasks from PowerShell
The CData ADO.NET Provider for Asana 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 Asana.
ADO.NET Provider
The ADO.NET Provider provides a SQL interface for Asana; this tutorial shows how to use the Provider to retrieve Asana data.
Once you have acquired the necessary connection properties, accessing Asana data in PowerShell can be enabled in three steps.
You can optionally set the following to refine the data returned from Asana.
- WorkspaceId: Set this to the globally unique identifier (gid) associated with your Asana Workspace to only return projects from the specified workspace. To get your workspace id, navigate to https://app.asana.com/api/1.0/workspaces while logged into Asana. This displays a JSON object containing your workspace name and Id.
- ProjectId: Set this to the globally unique identifier (gid) associated with your Asana Project to only return data mapped under the specified project. Project IDs can be found in the URL of your project's Overview page. This will be the numbers directly after /0/.
Connect Using OAuth Authentication
You must use OAuth to authenticate with Asana. OAuth requires the authenticating user to interact with Asana using the browser. See the "Getting Started" chapter of the help documentation for a guide to using OAuth.
-
Load the provider's assembly:
[Reflection.Assembly]::LoadFile("C:\Program Files\CData\CData ADO.NET Provider for Asana\lib\System.Data.CData.Asana.dll") -
Connect to Asana:
$conn= New-Object System.Data.CData.Asana.AsanaConnection("OAuthClientId=YourClientId;OAuthClientSecret=YourClientSecret;CallbackURL='http://localhost:33333';InitiateOAuth=GETANDREFRESH;") $conn.Open() -
Instantiate the AsanaDataAdapter, execute an SQL query, and output the results:
$sql="SELECT Id, WorkspaceId from projects" $da= New-Object System.Data.CData.Asana.AsanaDataAdapter($sql, $conn) $dt= New-Object System.Data.DataTable $da.Fill($dt) $dt.Rows | foreach { Write-Host $_.id $_.workspaceid }