![]() |
VOOZH | about |
This article illustrates using LINQ to access tables within the Postmark via the CData ADO.NET Data Provider for Postmark. To achieve this, we will use LINQ to Entity Framework, which facilitates the generation of connections and can be seamlessly employed with any CData ADO.NET Data Providers to access data through LINQ.
See the help documentation for a guide to setting up an EF 6 project to use the provider.
Enter your data source connection information.
Postmark uses server API tokens to authenticate requests. Each Postmark server has its own API token, which controls access to messages, bounces, templates, and statistics associated with that server.
To obtain your Server API Token, log in to your Postmark account and navigate to the server you want to connect to. Go to API Tokens under the server settings and copy the token labeled Server API token.
After setting the following connection properties, you are ready to connect:
Profile=C:\profiles\Postmark.apip;AuthScheme=APIKey;ProfileSettings="APIKey=your-server-api-token"
Once the authentication is configured, you can connect to Postmark and query data from any of the available tables such as OutboundMessages, Bounces, and Templates.
Below is a typical connection string:
Profile=C:\profiles\Postmark.apip;AuthScheme=APIKey;ProfileSettings="APIKey=your-server-api-token"
Using the entity you created, you can now perform select commands. For example:
APIEntities context = new APIEntities();
var bouncesQuery = from bounces in context.Bounces
select bounces;
foreach (var result in bouncesQuery) {
Console.WriteLine("{0} {1} ", result.Id, result.);
}
See "LINQ and Entity Framework" chapter in the help documentation for example queries of the supported LINQ.
Connect to live data from Postmark with the API Driver
Connect to Postmark