1
votes

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.

1
When you open the url in a browser - what does it show?user11909
@user2190035 same error: Server Error 404 - File or directory not found. The resource you are looking for might have been removed, had its name changed, or is temporarily unavailable. but this is because for some reason OrganizationServiceProxy is trying to add "?wsdl&sdkversion=90" to the url.BigThinker
and it is skipping the /api/ part.BigThinker
From the sample url you mention it looks like you are connecting to a on-premise instance, right? Check Connect to Microsoft Dynamics 365 as a primer - I'll post a working example later.Filburt

1 Answers

4
votes

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.