Tech Support > Microsoft Windows > Windows CRM > The request failed with HTTP status 401: Unauthorized.
The request failed with HTTP status 401: Unauthorized.
Posted by Mandar on September 22nd, 2005


Hi,

I want to test the CrmIncident.Retrieve method ,but i get this message
:

The request failed with HTTP status 401: Unauthorized.

bool result = false ;
// strServer should be set with the name of the platform Web server
string strServer = "success";
// virtualDirectory should be set with the name of the Microsoft CRM
// virtual directory on the platform Web server
string virtualDirectory = "mscrmservices";
string strDir = "http://" + strServer + "/" + virtualDirectory +
"/";
// BizUser proxy object
Microsoft.Crm.Platform.Proxy.BizUser bizUser = new
Microsoft.Crm.Platform.Proxy.BizUser ();
System.Net.ICredentials credentials = new
NetworkCredential("administrator","1Ecom2005","Eco mp");

bizUser.Credentials = credentials ;
bizUser.Url = strDir + "BizUser.srf";
// CRMIncident proxy object
Microsoft.Crm.Platform.Proxy.CRMIncident incident = new
Microsoft.Crm.Platform.Proxy.CRMIncident();
incident.Credentials =
System.Net.CredentialCache.DefaultCredentials;
incident.Url = strDir + "CRMIncident.srf";
string strErrorMsg = "";
string strIncidentId = oId;
try
{
Microsoft.Crm.Platform.Proxy.CUserAuth userAuth = bizUser.WhoAmI();

// Set up the columns that you want to retrieve
// Set up the columns that you want to retrieve
string strColumnSetXml = "<columnset>";
strColumnSetXml += "<column>incidentid</column>";
// Put the incidents in order by contract
strColumnSetXml += "<ascend>contractid</ascend>";
// Filter the incidents
strColumnSetXml += "<filter column='title' operator='like'
value='incident1,incident1)*' />";
strColumnSetXml += "</columnset>";



// Now retrieve the incidents
strErrorMsg = incident.Retrieve(userAuth, strIncidentId,
strColumnSetXml);
result=true;
}
catch (System.Web.Services.Protocols.SoapException err)
{
// Process the platform error here
strErrorMsg = ("ErrorMessage: " + err.Message + " " +
err.Detail.OuterXml + " Source: " + err.Source );
}
catch (Exception err)
{
// Process other errors here
strErrorMsg = ("ErrorMessage: " + err.Message );


the message in subject line is the exception errormessage,what am I
doing wrong,the crm server is on a domain controller ,i have put my
machine on the domain where my project is an asp.net project


is something wrong in code,web.config,or settings on server....??

Please Help,


Regards,


Mandar