Исключение Microsoft Dynamics 365 organizationName

Я пытаюсь получить список организаций с сервера, используя этот код:

var clientCredentials = new ClientCredentials();
clientCredentials.Windows.ClientCredential.Domain = "domain";
clientCredentials.Windows.ClientCredential.UserName = "user";
clientCredentials.Windows.ClientCredential.Password = "password";
var discoveryUri = new Uri(String.Format("http://{0}/XRMServices/2011/Discovery.svc", "10.20.30.40"));
var discoveryServiceProxy = new DiscoveryServiceProxy(discoveryUri, null, clientCredentials, null);
discoveryServiceProxy.Authenticate();
var retrieveOrganizationResponse = (RetrieveOrganizationsResponse)discoveryServiceProxy.Execute(new RetrieveOrganizationRequest());

но в последней строке выдает эту ошибку:

Название организации

Тип исключения такой:

http://schemas.microsoft.com/xrm/2011/Contracts/Discovery/IDiscoveryService/ExecuteDiscoveryServiceFaultFault

Пожалуйста, помогите с этой проблемой.


person Raul Mercado    schedule 16.05.2018    source источник


Ответы (1)


Я думаю, это может быть связано с тем, как вы формируете new RetrieveOrganizationRequest() - в частности, что вы не предоставляете никаких аргументов.

Здесь есть пример , который показывает, как получить список организации из Discovery Service.

// Retrieve details about all organizations discoverable via the
// Discovery service.
RetrieveOrganizationsRequest orgsRequest =
    new RetrieveOrganizationsRequest()
    {
        AccessType = EndpointAccessType.Default,
        Release = OrganizationRelease.Current
    };
RetrieveOrganizationsResponse organizations =
    (RetrieveOrganizationsResponse)service.Execute(orgsRequest);

// Print each organization's friendly name, unique name and URLs
// for each of its endpoints.
Console.WriteLine();
Console.WriteLine("Retrieving details of each organization:");
foreach (OrganizationDetail organization in organizations.Details)
{
    Console.WriteLine("Organization Name: {0}", organization.FriendlyName);
    Console.WriteLine("Unique Name: {0}", organization.UniqueName);
    Console.WriteLine("Endpoints:");
    foreach (var endpoint in organization.Endpoints)
    {
        Console.WriteLine("  Name: {0}", endpoint.Key);
        Console.WriteLine("  URL: {0}", endpoint.Value);
    }
}
person James Wood    schedule 16.05.2018