locked
Bad request answer to fetchXML containing an objectid attribute RRS feed

  • Question

  • Hello everybody,

    I want to use a fetchXML query to extract data. I have to explain you first my entities. I have an auto-referncing N:N relationship betwen contacts. I have a contact which has related contacts. I want to display all the activities of these related contacts. I've created this association and used the advanced find tool to create my fetchXML query. The query returns the expected result with my XMLhttprequest (WEB API). When I add the regardingobjectid as an attribute in this query I have a "bad request" answer. Each time I add a related entity objectid to my query it returns this error (I add a new column in my advanced find which is translated to an "attribute" markup in the fetchXML. Does anyone has an answer to this problem? Thank you for your help.

    fetch XML code:

    <fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="true">
      <entity name="activitypointer">
        <attribute name="activitytypecode" />
        <attribute name="subject" />
        <attribute name="statecode" />
        <attribute name="prioritycode" />
        <attribute name="modifiedon" />
        <attribute name="activityid" />
        <attribute name="regardingobjectid" />
        <order attribute="modifiedon" descending="false" />
        <link-entity name="contact" from="contactid" to="regardingobjectid" link-type="outer" alias="aa">
          <link-entity name="new_contact_contact" from="contactidtwo" to="contactid" visible="false" intersect="true">
            <link-entity name="contact" from="contactid" to="contactidone" alias="ab">
              <filter type="and">
                <condition attribute="contactid" operator="eq" uiname="Abraham McCormick" uitype="contact" value="{72E7CF00-F706-E711-80F5-5065F38B5691}" />
              </filter>
            </link-entity>
          </link-entity>
        </link-entity>
      </entity>
    </fetch>

    translated JavaScript code:

    req.open("GET", Xrm.Page.context.getClientUrl() + "/api/data/v8.2/activitypointers?fetchXml=%3Cfetch%20version%3D%221.0%22%20output-format%3D%22xml-platform%22%20mapping%3D%22logical%22%20distinct%3D%22true%22%3E%3Centity%20name%3D%22activitypointer%22%3E%3Cattribute%20name%3D%22activitytypecode%22%20%2F%3E%3Cattribute%20name%3D%22subject%22%20%2F%3E%3Cattribute%20name%3D%22statecode%22%20%2F%3E%3Cattribute%20name%3D%22prioritycode%22%20%2F%3E%3Cattribute%20name%3D%22modifiedon%22%20%2F%3E%3Cattribute%20name%3D%22activityid%22%20%2F%3E%3Cattribute%20name%3D%22regardingobjectid%22%20%2F%3E%3Corder%20attribute%3D%22modifiedon%22%20descending%3D%22false%22%20%2F%3E%3Clink-entity%20name%3D%22contact%22%20from%3D%22contactid%22%20to%3D%22regardingobjectid%22%20link-type%3D%22outer%22%20alias%3D%22aa%22%3E%3Clink-entity%20name%3D%22new_contact_contact%22%20from%3D%22contactidtwo%22%20to%3D%22contactid%22%20visible%3D%22false%22%20intersect%3D%22true%22%3E%3Clink-entity%20name%3D%22contact%22%20from%3D%22contactid%22%20to%3D%22contactidone%22%20alias%3D%22ab%22%3E%3Cfilter%20type%3D%22and%22%3E%3Ccondition%20attribute%3D%22contactid%22%20operator%3D%22eq%22%20uiname%3D%22Abraham%20McCormick%22%20uitype%3D%22contact%22%20value%3D%22%7B72E7CF00-F706-E711-80F5-5065F38B5691%7D%22%20%2F%3E%3C%2Ffilter%3E%3C%2Flink-entity%3E%3C%2Flink-entity%3E%3C%2Flink-entity%3E%3C%2Fentity%3E%3C%2Ffetch%3E", false);
    


    Friday, March 31, 2017 8:20 AM