-
Notifications
You must be signed in to change notification settings - Fork 0
Home
HubSpot is a popular customer relations management (CRM) platform that offers a REST API for third-party integrations. Trouble is, HubSpot hasn't done a good job of guiding developers through a simple setup and integration scenario. This document provides the simplest steps to get a HubSpot account, create your API key and set up a barebones MVC/HubSpot integration.
You can sign up for a free developer account on HubSpot. The developer account is limited in that you can work with the API to add Contacts to HubSpot but you don't get the Marketing dashboard to see a list of those contacts with the HubSpot UI. This was a very confusing waste of time. What you need is the full-featured trial version of HubSpot.
- Navigate to https://developers.hubspot.com/
- In the upper right area, click Create an Account.
- Fill in the developer account details (as shown in the image below) and click Start Building Apps:
HubSpot announces that your account is ready and then shifts to the Development screen.
- While still logged in to HubSpot with your developer account, click the Testing menu item at the top left area of the screen as shown in the following image:
- On the Testing page, near the bottom, click Start testing.
- On the Create Test Hub ID pop-up, provide a test hub name (for example, hubspotmvc) and click Create as shown in the image below:
The Testing page displays a grid with the Test Hub you just created, as shown in the following image:
- Click the name of the Test Hub to enter the Marketing Dashboard.
- Click the Profile and Preferences area in the top right of the screen:
- Click Integrations.
- On the Integrations screen click HubSpot API Key and then click Generate New Key:
The new HAPIkey appears along with the API Key History as shown below:
- Copy the HAPIKey to a file and save it for use in a following step. Do not publish your API key publicly.
Once you have a HubSpot Test Hub and API key, you can create an ASP.NET MVC application that inserts a contact and a company into the Test Hub. This topic uses a simple REST client to provide .NET bindings for the HubSpot CRM from https://github.com/dmitrybakaev/hubspot-rest-client
- In Visual Studio 2015 or later, create a new ASP.NET Web Application named HubSpotIntegrationExample (File > New Project > ASP.NET Web Application) choosing the MVC template.
- From GitHub, download the archive of the Visual Studio project from dmitrybakaev/hubspot-rest-client
- Unarchive the hubspot-rest-client to your local machine, retaining the folder structure.
- In the Visual Studio HubSpotIntegrationExample solution, add the HubSpotRestClient project (Add > Existing Project).
- In the Visual Studio HubSpotIntegrationExample project, add a reference to the HubSpotRestClient project.
- Ensure that the solution builds. (You may need to use the Nuget Package Manager to adjust versions of some components.)
- In the Visual Studio HubSpotIntegrationExample project, from the Controllers folder, open HomeController.cs in the editor.
- Replace the existing Index() method with the following code and substitute the unique HAPIKey (captured previously) in the highlighted area:
- Run the Web page.
- In HubSpot, navigate to your trial account as shown in the image below:
- From the upper left area, click Contacts > Contacts. Note that the contact has been inserted as shown below:
- From the upper left area, click Contacts, Companies. Confirm that the company has been inserted as shown below:
Rather than importing a library to insert the contact and company, you can create the required payload and post it using .NET code in your project.
This example shows a simplified use of the REST API where you manually build a JSON string containing the properties that you then post to the REST API as a byte array.