We have hosted CRM 4.0 and using the below code I am not able to connect to CRM Can anybody please help me
I am getting an Error from below line
RetrieveMultipleResponse resJobs = (RetrieveMultipleResponse)myCrm.Execute(objReqJobs);
The Error is "The request failed with HTTP status 404: Not Found."
main()
{
CrmService myCrm = new CrmService();
QueryExpression qeJobs = new QueryExpression();
qeJobs.EntityName = "account";
ColumnSet columnJobs = new ColumnSet(new string[] { "accountid", "name" });
qeJobs.ColumnSet = columnJobs;
qeJobs.AddOrder("createdon", OrderType.Ascending);
RetrieveMultipleRequest objReqJobs = new RetrieveMultipleRequest();
objReqJobs.Query = qeJobs;
objReqJobs.ReturnDynamicEntities = true;
//getting an Error from below line
RetrieveMultipleResponse resJobs = (RetrieveMultipleResponse)myCrm.Execute(objReqJobs);
BusinessEntityCollection becJobs = resJobs.BusinessEntityCollection;
int count = becJobs.BusinessEntities.Count;
}
private static CrmService IntiateCRMService()
{
try
{
if (objService != null) return objService;
CrmAuthenticationToken token = new CrmAuthenticationToken();
token.AuthenticationType = 2;
token.OrganizationName = "Guru";
objService = new CrmService();
objService.Url = "https://CRMURL/MSCRMServices/2007/CrmService.asmx";
objService.CrmAuthenticationTokenValue = token;
//objService.Credentials = System.Net.CredentialCache.DefaultNetworkCredentials;
string uname = @"Username";
objService.Credentials = new System.Net.NetworkCredential(username,uname, "Domainname");
return objService;
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
return null;
}
}