Hi Bipin,
The below method returns the contacts from the trial CRM instance, my understanding is the use of OrganizationServiceProxy at all should be failing and the code should be changed to use CrmServiceClient instead.
Thanks,
Chris
private static void getContacts()
{
using (OrganizationServiceProxy serviceProxy = new OrganizationServiceProxy(
new Uri("org-xyzabc.api.crm3.dynamics.com/.../Organization.svc"),
null,
getCredentials(),
null))
{
using (OrganizationServiceContext orgServiceCtx = new OrganizationServiceContext(serviceProxy))
{
var contactQuery = from c in orgServiceCtx.CreateQuery("contact")
select new
{
Contact = new
{
ContactId = c["contactid"],
ContactStateCode = c.Attributes.Contains("statecode") ? c["statecode"] : 999,
FirstName = c.Attributes.Contains("firstname") ? c["firstname"] : "?"
}
};
foreach (var contact in contactQuery)
{
Console.WriteLine("[+] Contact ID: " + contact.Contact.ContactId + " -> " + contact.Contact.FirstName);
}
}
}
}