Skip to main content
Skip table of contents

Connecting to Awin via SQL

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

Pre-requisites

  • You need an AccessToken to gain access to the API.

How to Connect

Run the following statements in the CData Virtuality Studio or the Web UI (remember to enter your credentials):

SQL
CALL SYSADMIN.createConnection (
    name => 'awin_src'
    ,jbossCLITemplateName => 'ws'
    ,connectionOrResourceAdapterProperties => 'EndPoint=https://api.awin.com'
);;

CALL SYSADMIN.createDataSource (
    name => 'awin_src'
    ,translator => 'awin'
    ,modelProperties => 'AccessToken=<AccessToken>'
    ,translatorProperties => ''
);;
 
-- The next statement is optional
CREATE VIEW awin.Credentials
AS
	SELECT 
		'<label_1>' AS label, 
		'<AccessToken_1>' AS accessToken
	UNION ALL
	SELECT
		'<label_2>' AS label, 
		'<AccessToken_2>' AS accessToken
	-- You may add additional pairs 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.

Please remember that you have to manually pass a label parameter to the procedures of the API, which will identify which credentials should be used in the request. If the multi-tenancy table is present, its name should be specified in the model properties, and in this case, the accessToken parameter may be omitted. Please make sure that it is present in the multi-tenancy table in this case. 

When you have entered both the accessToken parameter in the model properties and the value in the multi-tenancy table, you may specify the label default to direct the engine to use the value from the model properties string. 

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.