Creating CRM Organisation Service

Creating CRM Organisation Service :

Connecting to dynamics CRM through API with service proxy

// Credentials

 string username = "admin@xxxxx.onmicrosoft.com";
 string password = "xxxxxx";
 string url="https://xxxxxxx.api.crm.dynamics.com/XRMServices/2011/Organization.svc";
//Connection 
 Uri organisationurl = new Uri(url); 
ClientCredentials credentials = new ClientCredentials(); 
credentials.UserName.UserName = username; 
credentials.UserName.Password = password;

//Creating Service in 2 ways. Go through any of the following

//Method 1 
OrganizationServiceProxy service = new OrganizationServiceProxy(organisationurl, null, credentials, null);
service.ServiceConfiguration.CurrentServiceEndpoint.Behaviors.Add(new ProxyTypesBehavior());


//Method 2
 OrganizationServiceProxy proxy = new OrganizationServiceProxy(organisationurl, null, credentials, null);
proxy.EnableProxyTypes();
IOrganizationService service = (IOrganizationService)proxy;

 

It will connect & Enjoy 🙂

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s