function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Niels MuysewinkelNiels Muysewinkel 

integrate marketing cloud api using apex


Hello,

For our customer we are currently working on a solution design for building a local marketing tool for dealers/partners. 
Among the requirements there are several requests that require emails / campaigns / email sends / data extensions / ... to be created into our Marketing Cloud platform.

As a sort of POC for testing if this kind of items could be created via the API from APEX I have :
1. imported the WSDL for the Marketing Cloud API using wsdl to apex in my developer org
2. built a small class that should create a simple text email in to marketing cloud.

At this moment I'm having troubles saving the code. The code I have is using the same principles as the samples you can find here (https://developer.salesforce.com/docs/atlas.en-us.noversion.mc-apis.meta/mc-apis/creating_an_email_via_the_web_service_api.htm) and this gives me a compilation error on the following line of code

CreateResult[] results = proxy.Create(new CreateOptions(), new APIObject[] { email });

The error message is related to new APIObject[] { email } part where I try to add an object of type "Email" into an array of "APIObject". To me it sounds like an "inheritance" problem where the compiler does not detect that Email is inheriting from APIObject, while in .NET this does not seem to be an issue.

The question is: 
* is it at all possible to build this kind of integration using APEX and Marketing Cloud API?
* if it is not possible, are there any workarounds you can suggest us?
* if it is possible, what am I missing here? What am I doing wrong?