Skip to main content

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.

  1. Log into Connect Cloud, click Connections and click Add Connection WqHMPgtFmQ6KKT4D-oK6JNdRYD0th2lIzEb5mOWumFW9x6h68jLFh26i_BuSGofW0xM-l7C7_j7OdF623FnM5-wO-ql9Cc0F1pDjE1lPYpJSWYl5GHiOGfdNBUTcPKwpxlzayasIpsf_S9Ioww1zEkU
  2. Select "API" from the Add Connection panel
    Vev06l0Lzp56MRwV5pNkXRzz10NAocJl6GOKUWMOdvPSrg6NpC9lroVT0TOMPiyCOijEaBq1erdl3sLrtKODsSOWiEOBLhWVg8IhLC4xCkC6YQLQLUqdIyABR2ZB3kt24yMYuNbECdtx4c4o0XVY9xg
  3. 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.

  1. Set Name to "Authorization"
  2. Set Value to "Bearer <your Harvest personal access token>"

Harvest also requires a Harvest Account ID header.

  1. Click Add Header.
  2. Set Name to "Harvest-Account-ID"
  3. Set Value to your Harvest Account ID (visible when you view or create a PAT).

9zcdVF1D12H95Z6cNa1tl1YNJ4CQI0CVd3UuReCUtlA-17EFVGEb33EHoG1ojNTH8aWWk8saplgmWXjz1g9EWcwNZQoxzk6DAIbOuiLzJkCgzKnQGaeB5-gmoY8_4Y_kNte0scOn5j-Xo1FNKUW2Pss

View your Harvest Account ID and generate a Harvest personal access token

To generate a Harvest personal access token (PAT):

  1. Navigate to https://id.getharvest.com/developers and click "Create new personal access token." 
  2. Name the token and click "Create personal access token." 
  3. Make note of the token for the Authorization header.
  4. 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"
  }
}

 

Dc06k8JmIuJF3fa8vRWismk_rg2cjJBBydNQyYxnGXe9jb2PhHkEP12nNcNqPYATE3fPxcfFFaEAgFA99AUCkYjC7EzopC1Rm3vQ5JK81v8Tyzp3bB5Eg4AueRfSe_Xzw67N6zuFq_YL9Ncfp9CQtoA

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.

  1. Name your table "Users"
  2. Set Request URL to "https://api.getharvest.com/v2/users"
  3. Set Response Type to "JSON"

To configure the schema, scroll down to the "Table Data" section and click Configure.

  1. First, you’ll see the response. Click Next.
    FEfhKMtVWWUe3aJWtuk9vMz4SPtEwKV1pCUSCJZO-Jji1R4D_CkD46IHg34PzpBjcoiSm-65OQXzjqfRjD87go6XOggoHlRn3WxXyMHKr3FRz8jx_1QW6_GwZw7wKMMK0BXzO5zBcPzyA8lwNEBKW8M
  2. 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."
    vubMEKjMDDSt3C8r1tQp6Z1Y9wx382Qjt9Y9BzgHWjRTKNal0vChcqmlyE5xshyNBotHjnUFXK62I0TJs4e2Gk67YWsxCx_KLBaZ9-UGieb15JJbbIewY8Flb5nvHTXSqv4dwzK3vW7IbX-ngV6vvbY
  3. Review the preview results and click "Confirm."
    jqIuI5uYUuZHHL4aFkwM6SX9V6p9MLdCmQCPRXnitemB3SpfjuYST2R-jY3zSKYZ5_Lrwi2po7sOMQ45YM2eukjKzltbpTIx_PLpgaTsh5_GlpgnYPnI9mwZ1bAeCNyB8XcUsI3fqN29082hCdRabS4
  4. 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.

  1. Click on your username at the top right of the Connect Cloud app and click User Profile.
  2. On the User Profile page, scroll down to the Personal Access Tokens section and click Create PAT.
  3. Give your PAT a name and click Create. FW1C3fVHlXvD7d_MLxW50WTQZ4jk3Ig3-gDJm8XzPqPungXDf-Ek-1TT7GZZaux-BIbra_BoymaT91z4RUEK7E4g8zO7ncwjb5ShBZKlA_Pt504uFRcGv_z9r-67jVj3gd6QECRCph5mEQ5mSd475Ok
  4. 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.

  1. Navigate to the Data Explorer
  2. Select your Harvest connection to see the tables available (based on our previous configuration).
    26HkDKCXtimvEVAcupVB_0pL-XzJtDOqQifU9n1lHSP3fmiJf6NnULWOr3M8erTZUNCzfhpBw442QVxcvOEh-vZIAYd-RPXOR-nQGBIm6gTmDX_5K6zAzUpPoW-WO-9OoplCN9H2s9GwcNfjQK4qRB0
  3. Select the table you wish to view and click "Execute" to see the data returned.
    lNsCT45e15ggCdb573r9-8voiyj6lLzyIcldoOOMZE-6i5jRudwRmkHQEBjndqwayaYRNhjHTFUdU_b8l6XV_gxB7CuM4RbwknwUSZK8-w0X6YixZUfa4SLBMiVmH4AMz-0QwPzLl0p4rsP8WlFH-jg

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!

 

Be the first to reply!

Reply