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

Notifications

Announcements

No record found.

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans