How to Integrate Dynamics 365 (CRM) with Constant Contact

Many companies use a mix of Dynamics and other applications to handle their needs for CRM, customer outreach, and more.

In this article, I will show you how to integrate one or more Dynamics 365 CRM applications like Dynamics 365 Sales with the email management software Constant Contact, by building a Dataverse custom connector.

For your specific configuration, you may need the help of a skilled Dynamics partner. However, the guidance here will give you a clearer sense of a viable approach that your internal developer or a Dynamics partner could take to connect Dynamics CRM applications to a non-Microsoft application.

Note: There are now 5 Dynamics solutions that fulfil different CRM needs. In some contexts, you may also see those products referred to as “Customer Engagement” or “CE” apps.  All of these are based on Dataverse, and the integration described here will work no matter which of these apps you are using.

Legend

As a helpful guide, I am providing a legend for used abbreviations:

  • CC = Constant Contact
  • CE = Customer Engagement
  • DV = Dataverse
  • PA = Power Automate

Situation

As of June 2022, a pre-built template or connector (with triggers and actions) does not exist between the Dataverse (on which Dynamics Customer Engagement apps are built) and Constant Contact. For this reason, a custom connector is required to integrate data between the two systems. If an integration is needed and a custom connector is not used, third-party tools would be required.

How to Build a Custom Connector Between Dataverse and Constant Contact

Here are some items that need to be in place before beginning:

  • Customer Engagement license for any of the five D365 Customer Engagement (aka CRM) applications
  • Dataverse environment
  • Power Automate per User Plan license (or equivalent; needs to use premium features)
  • Constant Contact license and account
  • Internal developer or Dynamics partner with Power Automate experience
  • Understanding of Constant Contact API

Custom Connector Between Dynamics 365 (Dataverse) and Constant Contact

Dynamics 365 CE solutions like Dynamics 365 Sales are built on the Dataverse, which in turn is built on the Power Platform. This allows you to extend the functionality of your Dynamics 365 solution to work with other systems, including non-Microsoft systems like Constant Contact. And since CC has a robust open API, we can follow Microsoft’s instructions on how to build a custom connector with an open API definition.

The first time you try this, it may not be a straightforward process, because it appears the DV custom connector requirements do not match up with CC’s API. We will walk through these obstacles, and how to overcome each of them, as we create the custom connector.

Constant Contact

Register Application

To begin, navigate and log into your Constant Contact account and register your CC application by following these instructions.

It is important that you register the application, step 2, as this generates the API Key that will be used by the Dataverse custom connector. Copy and paste the API Key and secret in Notepad for later use.

Do not complete step 3 at this time; this will happen after you create the custom connector in the Power Platform.

Download CC API

While still in Constant Contact, navigate here and download the API as a YAML file. Save the API file to a location where you can easily find and utilize it.

Dataverse

Import Open API

Log into your Dataverse, navigate to the correct environment, expand Dataverse in the left navigation and click on Custom Connectors. Then click New custom connector and then click Import an OpenAPI file.

Dropdown menu in Dataverse, highlighting the option to Import an OpenAPI file

Provide a name for the custom connector that will be visible throughout the Power Platform and then import the Constant Contact file.

And here is where you will face the first challenge. The import process is looking for a JSON file, but Constant Contact only provides a YAML file.

Import process screen from Dataverse, highlighting the requirement for a JSON file

We can see that the swagger.yaml file is not showing in the File Explorer.

Thankfully for us, there is a wonderful online tool that will convert YAML to JSON.

Follow their process, and then upload the new JSON file:

Import screen from Dataverse, showing the new JSON file selected

Enter General Information

Once the new JSON file is successfully uploaded, you will be redirected to the first step of the custom connector process within Dataverse.

5 steps of the connector process within Dataverse: general, security, definition, code, and test

Confirm the information and click the Security link at the bottom right.

Enter in all the following information:

Authentication Type

OAuth 2.0

Identity Provider

Generic Oauth 2

Client id (API Key)

This is generated when you register the Constant Contact application.

Client secret

This is generated when you register the Constant Contact application.

Authorization URL (Get requests)

https://authz.constantcontact.com/oauth2/default/v1/authorize

Token URL (Post)

https://authz.constantcontact.com/oauth2/default/v1/token

Refresh URL

https://authz.constantcontact.com/oauth2/default/v1/token

Scope

contact_data, campaign_data, account_read, account_update, offline_access

(These may need to be different, depending on what you will need to do with the custom connector.)

Review CC’s user privileges to determine which roles need to be added to scope:

https://v3.developer.constantcontact.com/api_guide/scopes.html

Security details screen

Create Connector

After you have entered all this information, click Create connector at the top.

Resolve Errors

This is where you will find a mismatch of system requirements between the Dataverse custom connector and Constant Contact’s API. You will receive this error:

Your custom connector has been successfully created, but there was an issue converting it to WADL for Power Apps: An error occurred while converting OpenAPI file to WADL file. Error: ‘Operation id “getAuthCode” must specify either a default response or a 200-series response. Any other responses in the swagger is not supported by PowerApps client at JSON path paths[‘/idfed’].get’

It will also say, “The request failed with client error.”

At the top of the custom connector, there is a Swagger Editor switch:

Swagger Editor switch within step 3 of the custom connector process

Switch it on.

Now you will see a list of errors like the below:

Swagger code shown within Swagger Editor

Click anywhere in the Swagger code and on your keyboard hit CTRL-F to search the code. Type in “getAuthCode” and hit Enter. You will see the below:

Output from getAuthCode, showing three lines with errors: oath2_implicit, oath2_access_code, and api_key

Pay particular attention to the responses. There is only a 302 response, and the error message is indicating that we need a 200-series response, so we will need to add one.

Note the line number of the code (3539).

Now search for “responses” in the code.

I found this:

3 code lines, showing a 200 response.

Copy and paste the 200 and the description line into Notepad and adjust to as follows:

‘200’: {description: Request Successful}

Now paste this into the Swagger code. Now the getAuthCode responses will look like this:

5 code lines, showing the new 200 response inserted

After clicking Update connector at the top, the connector saves successfully and then we notice a successful message at the top:

Custom connector success message

You will, however, see some further errors, for instance,
Semantic error at paths./account/user/privileges.get.security.0

These errors may have to do with the /account/user/privileges endpoint (oauth2_implicit, oath2_access_code and api_key).

However, these are only semantic errors, and they can be safely ignored in this case.

You can jump to the next step, Test Custom Connector.

Or to explore those errors see below. Navigate to the Definition step, if not already there, and you will see some of the errors:

Dataverse Definition step showing error messages

Without a doubt, the most common type of error listed below was a semantic error:

Error message: Semantic error at paths./account/user/privileges.get.security.0

Navigating to the mentioned line, we see:

3 error lines in the code: oath2_implicit, oath2_access_code, and api_key]

These error lines for oauth2_implicit, oath2_access_code and api_key represent the /account/user/privileges endpoint.

Open a new browser tab and navigate to Constant Contact’s user privileges info.

Here we can see the privileges for this endpoint:

Constant contact user privileges showing the endpoint method and route

However, this endpoint does not need any privileges.

What does this mean? The Constant Contact OpenAPI file is not meshing with the Dataverse custom connector requirements. But because it is only a semantic error with no immediate steps of reconciliation, you can continue. (Remember, the custom connector did save successfully with no major errors.)

Test Custom Connector

We need to test our custom connector to ensure everything is in order. Navigate to the Test step and click New connection.

Dataverse screen showing test step

The following dialog box will appear. Click Create.

Constant Contact API dialog box, with Create button

Enter your Constant Contact credentials.

Constant Contact sign-in screen

For me, the dialog box closed, and the system navigated me to the Connections page:

Connections page showing CCAPI connected

At this point, the custom connector is all done. Now we need to update CC.

Constant Contact – Update Redirect URL

Inside the DV, the Redirect URL will be generated after you first save the custom connector, and it will be the following: https://global.consent.azure-apim.net/redirect

Insert the DV-generated Redirect URL into Constant Contact’s registered application’s Redirect URL value and save.

Inserting the redirect URL into Constant Contact

Test in Power Automate

To see if the custom connector is available, create a new Power Automate; for testing purposes, it can be a recurrence flow.

Click New step, and in the search for Choose an operation, type in the name you provided your custom connector; in this case, I searched for “ccapi” and received the below results:

Insert the custom connector as operation in Power Automate

After selecting GET Contacts Collection, you will need to sign into Constant Contact one more time.

Constant Contact sign in through Power Automate

Once verifying the CC credentials, the action will appear:

GET details within Power Automate

Inside CC, find an email that is represented and copy and paste it into the email value above. Manually test the flow and view the results:

Flow results showing outputs from GET contacts

Success! It ran beautifully and returned the expected results from the CC endpoint.

If you’d like assistance and advice from a partner with experience in Dynamics and the Power Platform, please contact us.

Dynamics 365 CRM How-To eGuide

41 pages of step-by-step instructions for 6 different key tasks in Dynamics 365 CRM apps. Includes interactions with Power Apps and Power Automate!

Get eGuide

Dynamics 365 CRM How-To eGuide

Get eGuide