0

SDKからコードを取得し、認証タイプを設定するために1つだけ変更を加えましたが、接続しようとすると「Unauthorized」エラーが発生します。

私のコードは次のとおりです。

// Set up the CRM Service.
CrmAuthenticationToken token = new CrmAuthenticationToken();
token.AuthenticationType = 2;
token.OrganizationName = "TESTCRM";


CrmService service = new CrmService();
service.Url = "https://testcrm.ifdtestsystem.com/MSCrmServices/2007/CrmService.asmx";
service.CrmAuthenticationTokenValue = token;
//service.Credentials = System.Net.CredentialCache.DefaultCredentials;
service.Credentials = new NetworkCredential("Bill", "Password");


// Create an account entity and assign data to some attributes.
account newAccount = new account();
newAccount.name = "Greg Bike Store";
newAccount.accountnumber = "123456";
newAccount.address1_postalcode = "98052";
newAccount.address1_city = "Redmond";


// Call the Create method to create an account.
Guid accountId = service.Create(newAccount);
4

2 に答える 2

0

このドキュメントには、CrmDiscoveryServiceを使用してチケットを取得し、CrmServiceを設定するための合理的なサンプルが含まれています。

すべての認証情報がチケット内にあるため、サービスのCredentialsプロパティは不要になることに注意してください。

お役に立てれば

于 2009-05-04T12:35:09.587 に答える