SQL Server guide

Reading data in SQL Server


This section covers steps for setting up Zendesk Connector in the ZappySys Data Gateway data source (based on API Driver) to read Zendesk data in SQL Server:

Create data source in Data Gateway based on ZappySys API Driver

In this section we will create a data source for Zendesk in the Data Gateway. Let's follow these steps to accomplish that:

  1. Download and install ODBC PowerPack (if you haven't already).

  2. Search for gateway in the Windows Start Menu and open ZappySys Data Gateway Configuration:

    Open ZappySys Data Gateway Service Manager
  3. Go to the Users tab and follow these steps to add a Data Gateway user:

    • Click the Add button
    • In the Login field enter a username, e.g., john
    • Then enter a Password
    • Check the Is Administrator checkbox
    • Click OK to save
    Data Gateway - Add User
  4. Now we are ready to add a data source:

    • Click the Add button
    • Give the Data source a name (have it handy for later)
    • Then select Native - ZappySys API Driver
    • Finally, click OK
    ZendeskDSN
    ZappySys API Driver
    Data Gateway - Add data source
  5. When the Configuration window appears give your data source a name if you haven't done that already, then select "Zendesk" from the list of Popular Connectors. If "Zendesk" is not present in the list, then click "Search Online" and download it. Then set the path to the location where you downloaded it. Finally, click Continue >> to proceed with configuring the DSN:

    ZendeskDSN
    Zendesk
    ODBC DSN Template Selection
  6. Select your authentication scenario below to expand connection configuration steps to:

    • Configure the authentication in Zendesk.
    • Enter those details into the ZappySys API Driver data source configuration.
    OAuth - Client Credentials (Server-to-Server)

    Zendesk authentication

    Recommended for unattended server-to-server automation. No interactive user login or refresh token is required. The OAuth client must be configured as a Confidential client in Zendesk. [API reference]

    Use OAuth - Client Credentials (Server-to-Server) for unattended applications such as ETL packages, scheduled jobs, services, data pipelines, and other server-side integrations.

    Recommended for unattended automation: This authentication method does not require an interactive user login and does not use a refresh token. When the access token expires, ZappySys automatically requests a new access token using the same Client ID and Client Secret.
    1. Sign in to Zendesk as an administrator.
    2. Go to Admin Center > Apps and integrations > APIs > Zendesk API.
    3. Open the OAuth Clients section and create an OAuth client.
    4. Configure the OAuth client as a Confidential client.
    5. Enter a unique Client ID.
    6. Copy the generated Client Secret and store it securely.
    7. Configure the permissions/scopes required by your integration.
    8. In the ZappySys connection, enter your Zendesk Sub Domain, Client ID, Client Secret, and desired Permissions.
    9. Click Test Connection.
    Security: Client Credentials should only be used in trusted server-side environments where the Client Secret can be stored securely. Do not expose the Client Secret in browser-side or client-side applications.
    The access token is associated with the Zendesk user linked to the OAuth client and inherits that user's permissions. For automated integrations, consider using a dedicated Zendesk service account with only the permissions required by the integration.

    No Redirect URL, browser login, authorization code, or refresh token is required for this authentication method.

    API Connection Manager configuration

    Just perform these simple steps to finish authentication configuration:

    1. Set Authentication Type to OAuth - Client Credentials (Server-to-Server) [OAuth]
    2. Optional step. Modify API Base URL if needed (in most cases default will work).
    3. Fill in all the required parameters and set optional parameters if needed.
    4. Finally, hit OK button:
    ZendeskDSN
    Zendesk
    OAuth - Client Credentials (Server-to-Server) [OAuth]
    https://[$Domain$].zendesk.com/api/v2
    Required Parameters
    Sub Domain (e.g. mycompany) Fill-in the parameter...
    OAuth Client ID Fill-in the parameter...
    OAuth Client Secret Fill-in the parameter...
    Permissions Fill-in the parameter...
    Optional Parameters
    RetryMode RetryWhenStatusCodeMatch
    RetryStatusCodeList 429
    RetryCountMax 5
    RetryMultiplyWaitTime True
    ODBC DSN OAuth Connection Configuration
    Find full details in the Zendesk Connector authentication reference.
    OAuth - User Login (Interactive)

    Zendesk authentication

    Authenticate through an interactive Zendesk login. Create an OAuth client in Zendesk Admin Center under Apps and integrations > APIs > Zendesk API > OAuth Clients. [API reference]

    Use OAuth - User Login (Interactive) when the integration should access Zendesk on behalf of a specific user.

    During initial setup, a browser window opens and the user signs in to Zendesk and authorizes the application. No Zendesk password is stored in the connection.

    1. Sign in to Zendesk as an administrator.
    2. Go to Admin Center > Apps and integrations > APIs > Zendesk API.
    3. Open the OAuth Clients section and create an OAuth client.
    4. Enter a unique Client ID.
    5. Copy the generated Client Secret and store it securely.
    6. Configure the following Redirect URL for the OAuth client:
      https://zappysys.com/oauth
    7. In the ZappySys connection, enter your Zendesk Sub Domain, Client ID, Client Secret, and desired Permissions.
    8. Start the authorization process and sign in to Zendesk when the browser opens.
    9. Approve access when prompted.
    10. Click Test Connection.
    Token renewal: Zendesk access tokens expire. ZappySys uses the OAuth refresh token to obtain new access tokens without requiring the user to sign in again. The latest refresh token must be stored securely because Zendesk rotates refresh tokens during renewal.
    If the refresh token expires, is revoked, or cannot be restored from the saved connection, the interactive Zendesk login process must be performed again.

    For unattended server-side integrations where you do not want to maintain a refresh token, consider OAuth - Client Credentials (Server-to-Server).

    API Connection Manager configuration

    Just perform these simple steps to finish authentication configuration:

    1. Set Authentication Type to OAuth - User Login (Interactive) [OAuth]
    2. Optional step. Modify API Base URL if needed (in most cases default will work).
    3. Fill in all the required parameters and set optional parameters if needed.
    4. Press Generate Token button to generate the tokens.
    5. Finally, hit OK button:
    ZendeskDSN
    Zendesk
    OAuth - User Login (Interactive) [OAuth]
    https://[$Domain$].zendesk.com/api/v2
    Required Parameters
    Sub Domain (e.g. mycompany) Fill-in the parameter...
    ClientId Fill-in the parameter...
    ClientSecret Fill-in the parameter...
    Permissions Fill-in the parameter...
    RedirectUrl Fill-in the parameter...
    Optional Parameters
    RetryMode RetryWhenStatusCodeMatch
    RetryStatusCodeList 429
    RetryCountMax 5
    RetryMultiplyWaitTime True
    ODBC DSN OAuth Connection Configuration
    Find full details in the Zendesk Connector authentication reference.
    Token Authentication (Legacy)

    Zendesk authentication

    Authenticate using Static Token instead of userid / password ([Token Access] option must be enabled under Admin Console > Channel > API > Settings and then Click [ADD API Token] to generate new token. These settings typically found here https://YOUR-SUB-DOMAIN.zendesk.com/agent/admin/api/settings [API reference]

    Use API Token authentication to authenticate with your Zendesk user email and a Zendesk API token instead of your password.

    Deprecated by Zendesk: Zendesk is removing API token authentication. Existing API tokens are scheduled to stop working on April 30, 2027. For new integrations, use OAuth instead.
    1. Sign in to Zendesk as an administrator.
    2. Go to Admin Center > Apps and integrations > APIs > Zendesk API.
    3. Make sure Token access is enabled.
    4. Create or select an existing API token.
    5. Copy the generated token and store it securely.
    6. Enter your Zendesk Sub Domain.
    7. Enter your Zendesk User ID / Email.
    8. Paste the API token into the Token field.
    9. Click Test Connection.
    Migration: For unattended ETL, scheduled jobs, and server-side integrations, use OAuth - Client Credentials (Server-to-Server).

    API Connection Manager configuration

    Just perform these simple steps to finish authentication configuration:

    1. Set Authentication Type to Token Authentication (Legacy) [Http]
    2. Optional step. Modify API Base URL if needed (in most cases default will work).
    3. Fill in all the required parameters and set optional parameters if needed.
    4. Finally, hit OK button:
    ZendeskDSN
    Zendesk
    Token Authentication (Legacy) [Http]
    https://[$Domain$].zendesk.com/api/v2
    Required Parameters
    Sub Domain (e.g. mycompany) Fill-in the parameter...
    UserId Fill-in the parameter...
    Token Fill-in the parameter...
    Optional Parameters
    RetryMode RetryWhenStatusCodeMatch
    RetryStatusCodeList 429
    RetryCountMax 5
    RetryMultiplyWaitTime True
    ODBC DSN HTTP Connection Configuration
    Find full details in the Zendesk Connector authentication reference.
    Basic Authentication (User ID + Password)

    Zendesk authentication

    Authenticate using your Zendesk user ID and password. Two-factor authentication (2FA) must be disabled, and Password Access must be enabled under Admin Console > Channels > API > Settings. [API reference]

    Use Basic Authentication to authenticate with your Zendesk user email and password.

    Important: This method cannot be used when two-factor authentication (2FA) is enabled for the Zendesk user. Password access to the API must also be enabled in Zendesk.
    1. Sign in to Zendesk as an administrator.
    2. Go to Admin Center > Apps and integrations > APIs > Zendesk API.
    3. Make sure Password access is enabled.
    4. Enter your Zendesk Sub Domain. For example, if your Zendesk URL is: https://mycompany.zendesk.com, enter mycompany.
    5. Enter your Zendesk User ID / Email and Password.
    6. Click Test Connection.
    Recommendation: For new integrations, OAuth is preferred over storing a user's password. For unattended server-side integrations, consider OAuth - Client Credentials (Server-to-Server).

    API Connection Manager configuration

    Just perform these simple steps to finish authentication configuration:

    1. Set Authentication Type to Basic Authentication (User ID + Password) [Http]
    2. Optional step. Modify API Base URL if needed (in most cases default will work).
    3. Fill in all the required parameters and set optional parameters if needed.
    4. Finally, hit OK button:
    ZendeskDSN
    Zendesk
    Basic Authentication (User ID + Password) [Http]
    https://[$Domain$].zendesk.com/api/v2
    Required Parameters
    Sub Domain (e.g. mycompany) Fill-in the parameter...
    UserName (2FA Must be OFF) Fill-in the parameter...
    Password Fill-in the parameter...
    Optional Parameters
    RetryMode RetryWhenStatusCodeMatch
    RetryStatusCodeList 429
    RetryCountMax 5
    RetryMultiplyWaitTime True
    ODBC DSN HTTP Connection Configuration
    Find full details in the Zendesk Connector authentication reference.
  7. Once the data source connection has been configured, it's time to configure the SQL query. Select the Preview tab and then click Query Builder button to configure the SQL query:

    ZappySys API Driver - Zendesk
    Read and write Zendesk data effortlessly. Manage tickets, users, and organizations — almost no coding required.
    ZendeskDSN
    Open Query Builder in API ODBC Driver to read and write data to REST API
  8. Start by selecting the Table or Endpoint you are interested in and then configure the parameters. This will generate a query that we will use in SQL Server to retrieve data from Zendesk. Hit OK button to use this query in the next step.

    SELECT * FROM Tickets
    Configure table/endpoint parameters in ODBC data source based on API Driver
    Some parameters configured in this window will be passed to the Zendesk API, e.g. filtering parameters. It means that filtering will be done on the server side (instead of the client side), enabling you to get only the meaningful data much faster.
  9. Now hit Preview Data button to preview the data using the generated SQL query. If you are satisfied with the result, use this query in SQL Server:

    ZappySys API Driver - Zendesk
    Read and write Zendesk data effortlessly. Manage tickets, users, and organizations — almost no coding required.
    ZendeskDSN
    SELECT * FROM Tickets
    API ODBC Driver-based data source data preview
    You can also access data quickly from the tables dropdown by selecting <Select table>.
    A WHERE clause, LIMIT keyword will be performed on the client side, meaning that the whole result set will be retrieved from the Zendesk API first, and only then the filtering will be applied to the data. If possible, it is recommended to use parameters in Query Builder to filter the data on the server side (in Zendesk servers).
  10. Click OK to finish creating the data source.

  11. Once done, go to the Network Settings tab and Add a firewall rule for inbound traffic:

    Data Gateway - Add firewall rule for inbound connections
    • This will initially allow all inbound traffic.
    • Click Edit IP filters to restrict access to specific IP addresses or ranges.
  12. Crucial Step: After creating or modifying the data source, you must:

    • Click the Save button to persist your changes.
    • Hit Yes when prompted to restart the Data Gateway service.

    This ensures all changes are properly applied:

    ZappySys Data Gateway - Save Changes
    Skipping this step may cause the new settings to fail, preventing you from connecting to the data source.

Read data in SQL Server via Data Gateway

After configuring your data source using the ZappySys ODBC Driver, the next mandatory step to read that data in SQL Server is to create a Linked Server. SQL Server requires a Linked Server definition to access any ODBC-based source through the ZappySys Data Gateway, allowing the source driver data to be queried using standard T-SQL.

There are two ways to create the Linked Server:
  • Method 1: Using a SQL Script automatically generated by the Data Gateway
  • Method 2: Using SQL Server UI (SSMS) to manually configure the Linked Server

Method 1: Using a SQL Script automatically generated by the Data Gateway

The fastest and most reliable way to create the Linked Server is to use the SQL Script generated by the Data Gateway. This ensures all settings are applied correctly with minimal manual steps.

  1. In the Data Gateway, open the App Integration tab.

  2. Update the prefilled Linked Server Name if you want to use a custom name.

  3. Select the ZendeskDSN data source which we created earlier as the Database.

  4. Choose the correct SQL Server version for your environment.

    • SQL 2019 or Lower (@provider='SQLNCLI11')
    • SQL 2022 or Higher (@provider='MSOLEDBSQL')
  5. Click Generate Code.

  6. In the generated script scroll down to 4. Attach Gateway login with linked server step, enter your Data Gateway admin username and password.

    'LS_TO_ZENDESK_IN_GATEWAY'
    ZappySys Data Gateway SQL Script
  7. Press Ctrl + A and Ctrl + C to copy the entire script.

    LS_TO_ZENDESK_IN_GATEWAY
    ZendeskDSN
    ZappySys Data Gateway App Integration - Generate SQL Script
  8. Paste the script into SQL Server Management Studio (SSMS) and run it.

    Execute the create linked server query in SSMS
  9. That's it linked server is created in the SQL Server.

  10. Finally, open a new query and execute a query we saved in one of the previous steps:

    SELECT * FROM OPENQUERY([LS_TO_ZENDESK_IN_GATEWAY], 'SELECT * FROM Tickets')
    Execute query at Linked Server to ZappySys Data Gateway in SSMS

    SELECT * FROM OPENQUERY([LS_TO_ZENDESK_IN_GATEWAY], 'SELECT * FROM Tickets')

 

Sample SQL Script for Creating a Linked Server in SQL Server

USE [master]
GO
--///////////////////////////////////////////////////////////////////////////////////////
--Run below code in SSMS to create Linked Server and use ZappySys Drivers in SQL Server
--///////////////////////////////////////////////////////////////////////////////////////

-- Replace YOUR_GATEWAY_USER, YOUR_GATEWAY_PASSWORD
-- Replace localhost with IP/Machine name if ZappySys Gateway Running on different machine other than SQL Server
-- Replace Port 5000 if you configured gateway on a different port


--1. Configure your gateway service as per this article https://zappysys.com/links?id=10036

--2. Make sure you have SQL Server Installed. You can download FREE SQL Server Express Edition from here if you dont want to buy Paid version https://www.microsoft.com/en-us/sql-server/sql-server-editions-express

--Uncomment below if you like to drop linked server if it already exists
--EXEC master.dbo.sp_dropserver @server=N'LS_TO_ZENDESK_IN_GATEWAY', @droplogins='droplogins'

--3. Create new linked server

EXEC master.dbo.sp_addlinkedserver
    @server = N'LS_TO_ZENDESK_IN_GATEWAY'  --Linked server name (this will be used in OPENQUERY sql
, @srvproduct=N''
---- For MSSQL 2012, 2014, 2016, 2017, and 2019 use below (SQL Server Native Client 11.0)---
, @provider=N'SQLNCLI11'
---- For MSSQL 2022 or higher use below (Microsoft OLE DB Driver for SQL Server)---
--, @provider=N'MSOLEDBSQL'
, @datasrc=N'localhost,5000' --//Machine / Port where Gateway service is running
, @provstr=N'Network Library=DBMSSOCN;'
, @catalog=N'ZendeskDSN' --Data source name you gave on Gateway service settings

--4. Attach gateway login with linked server

EXEC master.dbo.sp_addlinkedsrvlogin
@rmtsrvname=N'LS_TO_ZENDESK_IN_GATEWAY'  --linked server name
, @useself=N'False'
, @locallogin=NULL
, @rmtuser=N'YOUR_GATEWAY_USER' --enter your Gateway user name
, @rmtpassword='YOUR_GATEWAY_PASSWORD'  --enter your Gateway user's password
GO

--5. Enable RPC OUT (This is Optional - Only needed if you plan to use EXEC(...) AT YourLinkedServerName rather than OPENQUERY
EXEC sp_serveroption 'LS_TO_ZENDESK_IN_GATEWAY', 'rpc', true;
EXEC sp_serveroption 'LS_TO_ZENDESK_IN_GATEWAY', 'rpc out', true;

--Disable MSDTC - Below needed to support INSERT INTO from EXEC AT statement
EXEC sp_serveroption 'LS_TO_ZENDESK_IN_GATEWAY', 'remote proc transaction promotion', false;

--Increase query timeout if query is going to take longer than 10 mins (Default timeout is 600 seconds)
--EXEC sp_serveroption 'LS_TO_ZENDESK_IN_GATEWAY', 'query timeout', 1200;
GO

Method 2: Using SQL Server UI (SSMS) to manually configure the Linked Server

You can also create the Linked Server manually through SSMS if you prefer a visual setup. This method lets you configure the provider, data source, and security interactively.

  1. First, let's open SQL Server Management Studio, create a new Linked Server, and start configuring it:

    LS_TO_ZENDESK_IN_GATEWAY
    Microsoft OLE DB Driver for SQL Server
    localhost,5000
    ZendeskDSN
    ZendeskDSN
    SSMS SQL Server Configure Linked Server
    • For SQL Server 2012, 2014, 2016, 2017, and 2019, choose SQL Server Native Client 11.0 as the provider.
    • For SQL Server 2022 or higher, choose Microsoft OLE DB Driver for SQL Server as the provider.
  2. Then click on Security option and configure username we created in ZappySys Data Gateway in one of the previous steps, e.g. john:

    SSMS SQL Server Configure Linked Server User Name
  3. Optional step. Under the Server Options, Enable RPC and RPC Out and Disable Promotion of Distributed Transactions(MSDTC).

    RPC and MSDTC Settings

    You need to enable RPC Out if you plan to use EXEC(...) AT [LS_TO_ZENDESK_IN_GATEWAY] rather than OPENQUERY.
    If don't enabled it, you will encounter the Server 'LS_TO_ZENDESK_IN_GATEWAY' is not configured for RPC error.

    Query Example:

    DECLARE @MyQuery NVARCHAR(MAX) = 'SELECT * FROM Tickets';
    
    EXEC (@MyQuery) AT [LS_TO_ZENDESK_IN_GATEWAY];


    If you plan to use 'INSERT INTO <TABLE> EXEC(...) AT [LS_TO_ZENDESK_IN_GATEWAY]' in that case you need to Disable Promotion of Distributed Transactions(MSDTC).
    If don't disabled it, you will encounter the The operation could not be performed because OLE DB provider "SQLNCLI11" for linked server "MY_LINKED_SERVER_NAME" was unable to begin a distributed transaction. error.

    Query Example:

    INSERT INTO dbo.Products
    DECLARE @MyQuery NVARCHAR(MAX) = 'SELECT * FROM Tickets';
    
    EXEC (@MyQuery) AT [LS_TO_ZENDESK_IN_GATEWAY];
    

  4. Finally, open a new query and execute a query we saved in one of the previous steps:

    SELECT * FROM OPENQUERY([LS_TO_ZENDESK_IN_GATEWAY], 'SELECT * FROM Tickets')
    Execute query at Linked Server to ZappySys Data Gateway in SSMS

    SELECT * FROM OPENQUERY([LS_TO_ZENDESK_IN_GATEWAY], 'SELECT * FROM Tickets')

Zendesk Connector Examples

The ZappySys API Driver is a user-friendly interface designed to facilitate the seamless integration of various applications with the Zendesk API. With its intuitive design and robust functionality, the ZappySys API Driver simplifies the process of configuring specific API endpoints to efficiently read or write data from Zendesk.

Click here to find more Zendesk Connector examples designed for seamless integration with the ZappySys API ODBC Driver under ODBC Data Source (36/64) or ZappySys Data Gateway, enhancing your ability to connect and interact with Prebuilt Connectors effectively.

Consume Data inside your App / Programming Language

Once you know how to load data from Zendesk Connector, you can click on one of the below links to learn the steps how to consume data inside your App / Programming Language from Zendesk Connector.

ODBC inside ETL / Reporting / BI Tools

ODBC inside Programming Languages

Key features of the ZappySys API Driver include:

The API ODBC driver facilitates the reading and writing of data from numerous popular online services (refer to the complete list here) using familiar SQL language without learning complexity of REST API calls. The driver allows querying nested structure and output as a flat table. You can also create your own ODBC / Data Gateway API connector file and use it with this driver.

  1. Intuitive Configuration: The interface is designed to be user-friendly, enabling users to easily set up the specific API endpoints within Zendesk without requiring extensive technical expertise or programming knowledge.

  2. Customizable Endpoint Setup: Users can conveniently configure the API endpoint settings, including the HTTP request method, endpoint URL, and any necessary parameters, to precisely target the desired data within Zendesk.

  3. Data Manipulation Capabilities: The ZappySys API Driver allows for seamless data retrieval and writing, enabling users to fetch data from Zendesk and perform various data manipulation operations as needed, all through an intuitive and straightforward interface.

  4. Secure Authentication Integration: The driver provides secure authentication integration, allowing users to securely connect to the Zendesk API by inputting the necessary authentication credentials, such as API tokens or other authentication keys.

  5. Error Handling Support: The interface is equipped with comprehensive error handling support, ensuring that any errors or exceptions encountered during the data retrieval or writing process are efficiently managed and appropriately communicated to users for prompt resolution.

  6. Data Visualization and Reporting: The ZappySys API Driver facilitates the seamless processing and presentation of the retrieved data from Zendesk, enabling users to generate comprehensive reports and visualizations for further analysis and decision-making purposes.

Overall, the ZappySys API Driver serves as a powerful tool for streamlining the integration of applications with Zendesk, providing users with a convenient and efficient way to access and manage data, all through a user-friendly and intuitive interface.