- 18 Sep 2024
- 1 Minute to read
- DarkLight
Microsoft .NET Library
- Updated on 18 Sep 2024
- 1 Minute to read
- DarkLight
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 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 Connector = new ApiConnector("<endpoint_url>", "<username>", "<password>");
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 |
---|---|
RequestUrl | The request URL used to perform the API call. |
RequestApiMethod | The name of the API Methods that has been called. |
RequestHttpMethod | The HTTP method (such as GET, POST, or DELETE) that has been used to perform the API call. |
RequestPOSTData | The post data that has been sent with the API call. |
RequestDateTimeUtc | The UTC date-time at which the API call has been made. |
RawData | The serialized raw data that has been returned by the server. |
Content | An IInteropObject (which can be an InteropStructure or InteropStructureCollection) that contains the deserialized response. |
ExceptionStructure | The ExceptionStructure that contains additional information about the exception that has occurred. |
DateTimeUtc | The 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:
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:
yDatasource.Name = "MyDatasource";
Connector.Persist(Datasource);