By Hector Villafuerte
In this tutorial, I’ll show you, how to create a .NET application to create Leads in Microsoft Dynamics CRM 2011 On-Premise. The application type I’ll use will be a console application type. Even though the same code can be used by an other .NET application type like ASP .NET MVC, WCF Service, Web API, etc.
Download the Microsoft Dynamics CRM 2011 Software Development Kit (SDK)
Open Visual Studio 2012 and create a New project type “Console Application”. Named the project: LeadImport.
Add the following assemblies references to your project:
Add also reference to: System.Runtime.Serialization and System.ServiceModel
The following screen show you, how the References should look like in the Solution Explorer.
Open your browser and go to your CRM On-Premise server. Click Settings and then click on Developer Resources
This screen shows the Service Endpoints. Click the Organization Service URL.
Copy the URL from the browser URL address.
The code is shown below. Paste the Organization Service URL in the organizationUri creation.
new ClientCredentials() will capture the currently user logged credentials.
Build and test the application. Verify in MS CRM if the new lead was created.
Click the newly created lead and verify that the field were correctly populated.
This code applies to MS Dynamics CRM On-Premise. The concept is similar for deployments using IFD (Internet Facing Deployment). Now, CRM Online needs Claims Authentication and some extra steps to connect to MS Online CRM Services.