none
Request URL Too Long for fetchXml query types

    Question

  • I'm using CRM 2016 web api with fetchxml query parameter, but my query is too long it's simulate the IN operator were the number of parameters passed in the IN list are 300 elements and some times will be more than that.

    So my problem is the query are too big for a GET HTTP Request. I have tried to send the query in the http message body but that didn't work so what is the solution for this problem?

    Here's a code snippet of the fetchxml query that I used:




        

        <fetch mapping="logical" distinct="true">
           <entity name="entity">
              <attribute name="new_classopportunityid" />
              <attribute name="new_trainingproduct" />
              <attribute name="new_gtgstatus" />
              <attribute name="new_scheduledstartdate" />
              <attribute name="new_scheduledenddate" />
              <attribute name="new_remainingnumberofseats" />
              <attribute name="new_liveclassroom" />
              <attribute name="new_maxlive" />
              <attribute name="new_xavieruniversity" />
              <attribute name="new_partnerlive" />
              <attribute name="new_blended" />
              <filter>
                 <condition attribute="new_classopportunityid" operator="in">
                    <value>001943ea-e263-e611-8158-00155d002810</value>
                    <value>0071e4ea-bd9b-e611-8163-00155d002810</value>
                    <value>00c32774-1c8f-e611-8161-00155d002810</value>
                    <value>00d513fa-f0bb-e611-8169-00155d002810</value>
                    <value>....</value>
                    <value>....</value>
                    <value>....</value>
                 </condition>
              </filter>
           </entity>
        </fetch>

    The CRM web api endpoint that I request is :

       

         GET http://<org>/api/data/v8.0/<entity>?fetchXml=<fetch mapping="logical" distinct="true">
               <entity name="entity">
                  <attribute name="new_classopportunityid" />
                  <attribute name="new_trainingproduct" />
                  <attribute name="new_gtgstatus" />
                  <attribute name="new_scheduledstartdate" />
                  <attribute name="new_scheduledenddate" />
                  <attribute name="new_remainingnumberofseats" />
                  <attribute name="new_liveclassroom" />
                  <attribute name="new_maxlive" />
                  <attribute name="new_xavieruniversity" />
                  <attribute name="new_partnerlive" />
                  <attribute name="new_blended" />
                  <filter>
                     <condition attribute="new_classopportunityid" operator="in">
                        <value>001943ea-e263-e611-8158-00155d002810</value>
                        <value>0071e4ea-bd9b-e611-8163-00155d002810</value>
                        <value>00c32774-1c8f-e611-8161-00155d002810</value>
                        <value>00d513fa-f0bb-e611-8169-00155d002810</value>
                        <value>....</value>
                        <value>....</value>
                        <value>....</value>
                     </condition>
                  </filter>
               </entity>
            </fetch>

    This is the response I got from the api.

        Error code: 414: HTTP/1.1 414 Request-URI Too Long  Response :  "<!DOCTYPE HTML PUBLIC \"-\/\/W3C\/\/DTD HTML 4.01\/\/EN\"\"http:\/\/www.w3.org\/TR\/html4\/strict.dtd\">\r\n<HTML><HEAD><TITLE>Request URL Too Long<\/TITLE>\r\n<META HTTP-EQUIV=\"Content-Type\" Content=\"text\/html; charset=us-ascii\"><\/HEAD>\r\n<BODY><h2>Request URL Too Long<\/h2>\r\n<hr><p>HTTP Error 414. The request URL is too long.<\/p>\r\n<\/BODY><\/HTML>\r\n" [] []
    Saturday, January 14, 2017 7:48 PM

Answers