web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

ODATA Web API CRM Online.. How to query more than 5000 records

(0) ShareShare
ReportReport
Posted on by

I am using ODATA Web API and it return only 5000 records using below command. How to get all records from that entity ?

HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Get, "api/data/v8.2/products" + queryOptions);

response = await httpClient.SendAsync(request );

myresult = JsonConvert.DeserializeObject<JObject>(response.Content.ReadAsStringAsync().Result);

myresult["value"].Count()

 

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    NILANKA SEKHAR PAUL Profile Picture
    340 on at

    Hi Sanjay,

    Can you please look into the below URLs.

    https://softchief.com/2016/02/20/retrieve-more-than-5000-records-in-dynamics-crm/

    https://nishantrana.me/2016/02/11/get-total-count-of-records-in-crm-more-than-5000/

    Thanks 

    Nilanka Sekhar Paul

  • Verified answer
    Web API ODATA Query using C3 Profile Picture
    on at

    Thank you Nilanka for response.

    I am not using XML but plan API calls.

    Here with code I am using and look like using page2Uri validating for remaining pages...

    So far it worked for one entity and will test for other entities.

    HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Get, "api/data/v8.2/products" + queryOptions2);

        response = await httpClient.SendAsync(request, HttpCompletionOption.ResponseHeadersRead);

       if (response.StatusCode == HttpStatusCode.OK) {

           contact1 = JsonConvert.DeserializeObject<JObject>(response.Content.ReadAsStringAsync().Result);

           console.WriteLine(contact1);

           page2Uri = null;

           if ( contact1["@odata.nextLink"] != null )

           page2Uri = contact1["@odata.nextLink"].ToString(); //This URI is already encoded.

           while (page2Uri != null)

           {

              request = new HttpRequestMessage(HttpMethod.Get, page2Uri);

              response = await httpClient.SendAsync(request);

              if (response.StatusCode == HttpStatusCode.OK) //200  {

                 contact1 = JsonConvert.DeserializeObject<JObject>(response.Content.ReadAsStringAsync().Result);

                 console.WriteLine(contact1);

                 if (contact1["@odata.nextLink"] == null)

                     page2Uri = null;

                 else

                     page2Uri = contact1["@odata.nextLink"].ToString(); //This URI is already encoded.

               }

               else

                  page2Uri = null;

             } // end while

         Console.WriteLine("Done with Web API Call '{0}'", DateTime.Now.ToString("h:mm:ss tt"));

     } // end if

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Congratulations to our 2025 Community Spotlights

Thanks to all of our 2025 Community Spotlight stars!

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
JS-09031509-0 Profile Picture

JS-09031509-0 3

#2
AS-17030037-0 Profile Picture

AS-17030037-0 2

#2
Mark Eckert Profile Picture

Mark Eckert 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans