Microsoft .NET Library
  • 18 Sep 2024
  • 1 Minute to read
  • Dark
    Light

Microsoft .NET Library

  • Dark
    Light

Article summary

General

This library can be used in .NET projects (C#, Visual Basic .NET, etc.) to connect to the API. It consists of two files that need to be referenced which are both located in the SDK\Library folder of the root installation directory:

  • MailAndDeploy.Api.Client.dll
  • MailAndDeploy.Interop.dll

The file Newtonsoft.Json.dll located in the same directory needs to be published alongside the assemblies specified above.

Connecting to the API

The connection to the API can be established using an instance of the class MailAndDeploy.Api.Client.ApiConnector for which to constructors are available.

The following constructor can be used if you want to connect to the API using access key Authentication:

APIConnector Constructor C# Syntax

ApiConnector Connector = new ApiConnector("<endpoint_url>", "<access_key>");

You have to pass the endpoint URL (that is the URL of the API Service) and the access key. The following constructor can be used if you want to connect using the custom username and password of a User:

APIConnector Constructor C# Syntax

ApiConnector Connector = new ApiConnector("<endpoint_url>", "<username>", "<password>");

NOTE

The User whose access key or custom username and password you provide needs be of type API User or Administrator.

Making API Calls

The instantiated ApiConnector can then be used to perform API calls; the object has methods for every available API Method. If an API call fails, an ApiException which has a property named ApiResponse that exposes the following properties:

Name

Description
RequestUrlThe request URL used to perform the API call.
RequestApiMethodThe name of the API Methods that has been called.
RequestHttpMethodThe HTTP method (such as GET, POST, or DELETE) that has been used to perform the API call.
RequestPOSTDataThe post data that has been sent with the API call.
RequestDateTimeUtcThe UTC date-time at which the API call has been made.
RawDataThe serialized raw data that has been returned by the server.
ContentAn IInteropObject (which can be an InteropStructure or InteropStructureCollection) that contains the deserialized response.
ExceptionStructureThe ExceptionStructure that contains additional information about the exception that has occurred.
DateTimeUtcThe UTC date-time at which the response has been received.

Examples

The following example returns a DatasourceStructure that represents the Datasource with ID 947667f3-665b-4246-8073-95de881225b1:

GetDatasource Example C# Syntax

DatasourceStructure Datasource = Connector.GetDatasource(new Guid("947667f3-665b-4246-8073-95de881225b1"));

The following code changes the name of the queried datasource to MyDatasource and then persists it:

Persist Example C# Syntax

yDatasource.Name = "MyDatasource";
Connector.Persist(Datasource);


Was this article helpful?