简体   繁体   中英

Show more than 5000 records from CRM in C#

I am trying to understand how FetchXml works (or any other method) because I want to retrieve and process more than the limit of 5000 records that CRM returns on the api call below.

My base url looks like this: http://crm.domain.com:1234/api/data/v8.0/

the resource is: emails

and query options are: $top=50000&$filter=description ne null and not contains(sender, '@not-interesting.com')

I'm trying to copy the code from https://docs.microsoft.com/en-us/previous-versions/dynamicscrm-2016/developers-guide/gg327917(v=crm.8)?redirectedfrom=MSDN

but I'm having issues with creating the OrganizationServiceProxy object like this:

var creds = new ClientCredentials();
creds.UserName.UserName = CrmApiUsername;
creds.UserName.Password = CrmApiPassword;

using (var _serviceProxy = new OrganizationServiceProxy(
            new Uri(CrmApiBaseAddress), null, creds, null))
        {
            // This statement is required to enable early-bound type support.
            _serviceProxy.EnableProxyTypes(); // ...

I'm getting an error:

Metadata contains a reference that cannot be resolved: ' http://crm.domain.com:1234/data/v8.0/?wsdl&sdkversion=90 '.' WebException: The remote server returned an error: (404) Not Found.

You mixed up these two:

  1. Web API - which was available after v8.0
  2. 2011 endpoint - which is deprecated now but was available for really long time

Read more

When you use web api the url will be like: https://yourcrm.crm#.dynamics.com/api/data/v8.0/

In case of Organization Service Proxy still the 2011 endpoint: https://yourcrm.crm.dynamics.com/XRMServices/2011/Organization.svc

For breaking the 5000 records limitation & getting more than 5k records, the pagination concept has to be used. How to fetch more than 5000 entities from CRM

For more ideas, I have answered in this SO thread about other options.

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM