I'm trying to get the list of organizations from a server using this code:
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());
but in the last line throws this error:
organizationName
the Exception type is this:
Please your help with this issue.
I think it might be to do with how your are forming the new RetrieveOrganizationRequest()
- specifically, that your don't supply any arguments.
There is an example here , that shows how to get the list of organizations from the 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);
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.