The API Connector in CData Connect Cloud lets you connect to any cloud-based API that produces XML or JSON data. When paired with the Harvest Time Tracking service API, customers can access Harvest data from their favorite tools, applications, and platforms.
For this article, we will simply access the data in Connect Cloud’s Data Explorer, but you’ll be able to access your data from any of the supported clients.
Connect to Harvest in Connect Cloud
CData Connect Cloud uses a straightforward, point-and-click interface to connect to data sources.
- Log into Connect Cloud, click Connections and click Add Connection
- Select "API" from the Add Connection panel
- Next name the connection and configure the Global Settings.
Authentication
By default, an API connector is set to No Auth for its Authentication Type. The Harvest API requires a Harvest personal access token in an Authorization header (see below), so leave Type as "No Auth."
Headers
Since Harvest uses a Bearer token, we have to add a specific Authorization header.
- Set Name to "Authorization"
- Set Value to "Bearer <your Harvest personal access token>"
Harvest also requires a Harvest Account ID header.
- Click Add Header.
- Set Name to "Harvest-Account-ID"
- Set Value to your Harvest Account ID (visible when you view or create a PAT).
View your Harvest Account ID and generate a Harvest personal access token
To generate a Harvest personal access token (PAT):
- Navigate to https://id.getharvest.com/developers and click "Create new personal access token."
- Name the token and click "Create personal access token."
- Make note of the token for the Authorization header.
- Make note of the Account ID for the Harvest-Account-ID header.
Pagination
The Harvest API uses links in the API response body for pagination. Set the pagination Type to "URL" and set Response Body to "/links/next" (based on the path of the "next" link in the response).
{
"clients": "
"{2000 client objects}"
],
"page": 1,
"total_pages": 3,
"total_entries": 257,
"next_page": 2,
"previous_page": null,
"links": {
"first": "https://api.harvestapp.com/v2/clients?page=1&per_page=2000&ref=first",
"next": "https://api.harvestapp.com/v2/clients?cursor=eyJhZnRlciI6eyJpZCI6MzAwN319&per_page=2000&ref=next_cursor",
"previous": null,
"last": "https://api.harvestapp.com/v2/clients?page=3&per_page=2000&ref=last"
}
}
Advanced
The Verbosity field should be left at 1 unless required for troubleshooting purposes.
After creating the API connection, proceed to Creating Tables.
Create Harvest tables
When creating tables for Harvest, it’s important to remember that you need to create a table for each API endpoint you wish to work with. We’ll create a table for the Users endpoint, but the principles apply for all of the other endpoints. Navigate to the Tables tab and click Add.
- Name your table "Users"
- Set Request URL to "https://api.getharvest.com/v2/users"
- Set Response Type to "JSON"
To configure the schema, scroll down to the "Table Data" section and click Configure.
- First, you’ll see the response. Click Next.
- Select the part of the response that represents the repeated elements you wish to see as rows and the fields you wish to see as columns. Then click "Next."
- Review the preview results and click "Confirm."
- Click "Save" to finalize your table.
Repeat the above process for any other API endpoints you wish to work with.
Add a Personal Access Token
While not necessary for this article, if you want to connect to Harvest from a service, application, platform, or framework that does not support OAuth authentication, you can create a Personal Access Token (PAT) in Connect Cloud to use for authentication. Best practices would dictate that you create a separate PAT for each service, to maintain granularity of access.
- Click on your username at the top right of the Connect Cloud app and click User Profile.
- On the User Profile page, scroll down to the Personal Access Tokens section and click Create PAT.
- Give your PAT a name and click Create.
- The personal access token is only visible at creation, so be sure to copy it and store it securely for future use.
View Harvest data in the Data Explorer
With the connection and tables configured, we are ready to work with Harvest data in our favorite tools and applications. For now, we'll view the data in the Connect Cloud Data Explorer.
- Navigate to the Data Explorer
- Select your Harvest connection to see the tables available (based on our previous configuration).
- Select the table you wish to view and click "Execute" to see the data returned.
Free trial & more information
To learn more about CData Connect Cloud and get live data access to your API data (and data from 100+ other SaaS, Big Data, and NoSQL sources) directly from your cloud applications, visit our CData Connect Cloud page or sign up for a free trial today!