.NET

To use the API within .NET is very simple. You will need to add the API as a web reference within Visual Studio. This document will show you how to use the .NET 2.0 web reference instead of the newer 3.0 service reference procedure. You can you this by right clicking on the project in the solution explorer and click “add service reference”, then click on the “advanced” button at the bottom

Then click the add web reference button



This will bring up the add web reference screen. The URL to enter is http://apiconnector.com
– if this is successful you should see the following details then simply click add reference.



The API Web Reference will then have been added to your solution.

Now you can start creating your integration

The first methods we will go through are returning data as these methods are simpler in structure. The below example is how to retrieve a campaign which is already in BrotherMailer



The below diagram show in more detail the structure of creating the instance of the API 

This class is quite self explanatory, it creates an instance of the API and the calls the getCampaign method with the required arguments. It will return the campaign as a campaign object called campaign. So you could the get the information about the campaign like

string html = campaign.HTMLContent;

This will create a string call html with the HTML of the campaign in, you will be able to do this for all of the contents of the campaign object (to see the structure of the any of the objects please look at the apiconnector.com site)

Or you can look at the campaign object e.g.



The same structure of class is used to retrieve data for other objects e.g. a contact



With the contact object you will notice that the datafields are an object within the contact object e.g.



The datafields object contacts two arrays, one called keys which is an array of strings which contains the names of the dataFields, and an 2nd array called values which is a array of objects. The values objects contains the values of the dataFields, it is an array of objects as it is capable of containing strings, ints, Booleans and dates.

You can get the values of these by:



Then you can iterate through the arrays to get the values out.

Inserting data will require more code as you need to populate the fields before you call the method, the below method is inserting a campaign



Inserting a contact is done in the same way, except you have the datafields object to insert as well, the code for this looks like



These are the basic methods of the API in .NET, if you find you have any problems with these then please contact support@brothermailer.com