Ich verwende Ich bin auf einem Remote-Server für den Zugriff auf Visual Studio sowie MS CRM angemeldet. Ich habe Beispielcode aus SDK genommen und versuche, den Code auszuführen:MS crm Kontoerstellung: System.Net.WebException: Die Anfrage ist fehlgeschlagen mit HTTP-Status 401: Nicht autorisiert
CrmAuthenticationToken token = new CrmAuthenticationToken();
token.AuthenticationType = 0;
token.OrganizationName = "AdventureWorksCycle";
CrmService service = new CrmService();
service.Url= "http://10.16.16.205:5555/mscrmservices/2007/crmservice.asmx";
service.CrmAuthenticationTokenValue = token;
service.Credentials = new System.Net.NetworkCredential"username", "password", "domain");
// Create the account object.
account account = new account();
// Set the properties of the account object.
account.name = "Fourth Coffee123";
account.address1_line1 = "29 Market St.";
account.address1_city = "Sam";
account.address1_stateorprovince = "MT1";
account.address1_postalcode = "9999";
account.donotbulkemail = new CrmBoolean();
account.donotbulkemail.Value = true;
// Create the target object for the request.
TargetCreateAccount target = new TargetCreateAccount();
// Set the properties of the target object.
target.Account = account;
// Create the request object.
CreateRequest create = new CreateRequest();
// Set the properties of the request object.
create.Target = target;
// Execute the request.
CreateResponse created = (CreateResponse)service.Execute(create);
I Crm Web Service für diesen verwenden, aber sein Wurf Ausnahme:
Ausnahmedetails:
System.Net.WebException: The request failed with HTTP status 401: Unauthorized.
Source Error:
Line 114: [return: System.Xml.Serialization.XmlElementAttribute("Response")]
Line 115: public Response Execute(Request Request) {
Line 117: Request});
Line 118: return ((Response)(results[0]));