Skip to main content
Skip table of contents

Connecting to Hubspot via SQL

You can use SQL to connect to Hubspot in the Data Virtuality Studio or the Code Editor in the Web UI.

Pre-requisites

  • You need the endpoint, the client pair, RefreshToken for gaining access to the API. We recommend that you use only one authorization method.

How to Connect

Before you start retrieving data, you need to run the connector script for Hubspot in the Data Virtuality Studio or the Web UI and input your credentials in the following line: 

SQL
CALL SYSADMIN.createConnection(
    name => 'hubspot_v2_src',
    jbossCliTemplateName => 'ws',
    connectionOrResourceAdapterProperties => 'EndPoint=https://api.hubapi.com,ClientId=<ClientId>,ClientSecret=<ClientSecret>,RefreshToken=<RefreshToken>'
);;
 
 
CALL SYSADMIN.createDatasource(
    name => 'hubspot_v2_src',
    translator => 'hubspot_v2',
    modelProperties => 'cleanupMethod=DELETE'
);;
 
CREATE VIEW hubspot_v2.Credentials
AS
SELECT
        '<label_1>' AS label,
        '<EndPoint_1>' AS EndPoint,
        '<ClientId_1>' AS ClientId,
        '<ClientSecret_1>' AS ClientSecret,
        '<RefreshToken_1>' AS RefreshToken
UNION ALL
SELECT
        '<label_2>' AS label,
        '<EndPoint_2>' AS EndPoint,
        '<ClientId_2>' AS ClientId,
        '<ClientSecret_2>' AS ClientSecret,
        '<RefreshToken_1>' AS RefreshToken
-- You may add additional sets using 'UNION ALL', making sure labels are unique
;;

You may optionally add a multi-tenancy table if you wish to access data from multiple accounts in the API.

Keep in mind that you have to mnually pass a label parameter to the API procedures which will identify which credentials should be used in the request. If you are not using multi-tenancy, remove the multitenancy_tablename parameter from the model properties, as the default value is not intended to be present in production environments.

JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.