Skip to main content

Notifications

Community site session details

Community site session details

Session Id : 1OveuX1SXU/B1VRymeFnga
Power Pages - Power Apps Portals
Suggested answer

FetchXML with Web API Fails When Using Multiple link-entity Elements

Like (1) ShareShare
ReportReport
Posted on 25 Mar 2025 10:31:09 by 24
I am using FetchXML queries with the Web API in Power Pages to retrieve data with multiple link-entity elements. According to the documentation, FetchXML supports up to 10 link-entity elements. However, when I include more than 1 link-entity in my FetchXML query, I receive a "Web API is not available" or similar error. The query works fine with a single link-entity, but adding more causes it to fail.
 
var fetchXml = `<fetch count="10" page="1" returntotalrecordcount="true">
  <entity name="primary_entity">
    <attribute name="recordid" />
    <link-entity name="related_entity_1" from="id" to="related_id_1" alias="alias1" link-type="outer">
      <attribute name="field1" />
    </link-entity>
    <link-entity name="related_entity_2" from="id" to="related_id_2" alias="alias2" link-type="outer">
      <attribute name="field2" />
    </link-entity>
  </entity>
</fetch>`;
$.ajax({
    type: "GET",
    url: "/_api/primary_entities?fetchXml=" + encodeURIComponent(fetchXml),
    success: function (res) {
        console.log(res);
    },
    error: function (xhr) {
        console.error(xhr.responseText);
    }
});

Here it works for when use one link-entity but for two it states web api is not available.

Is there a specific limitation when using multiple link-entity elements in FetchXML through the Web API?

Categories:
  • Suggested answer
    Fubar Profile Picture
    7,850 Super User 2025 Season 1 on 25 Mar 2025 at 21:59:44
    FetchXML with Web API Fails When Using Multiple link-entity Elements
    Not sure if this is the issue or not, but there is a known issue with complex queries when the system adds the extra pieces for the Table Permissions (i.e. it adjusts your query to add the permissions scope like account and contact scope).
     
    You can test this by setting table permissions to Global as global does not alter the query.
     
    My other thought would be that it may not like it as they are both Outer joins - but if thats the case may be more of a bug..
  • CU26111754-0 Profile Picture
    24 on 25 Mar 2025 at 14:17:33
    FetchXML with Web API Fails When Using Multiple link-entity Elements
    I have created the xml using fetchxmlbuilder. From this fetch if i remove one entity then its work fine. 
     
    Also the error “Web Api is not available” i encountered come when site settings is not available but in this i have ensure that they are created. 
  • bscarlavai33 Profile Picture
    583 Super User 2025 Season 1 on 25 Mar 2025 at 13:03:42
    FetchXML with Web API Fails When Using Multiple link-entity Elements
    That should be fine. Maybe there is some sort of syntax issue.
     
    Are you able to run your Fetch XML using XrmToolBox and see if it returns a result? https://www.xrmtoolbox.com/plugins/Cinteros.Xrm.FetchXmlBuilder/

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

Understanding Microsoft Agents - Introductory Session

Confused about how agents work across the Microsoft ecosystem? Register today!

Warren Belz – Community Spotlight

We are honored to recognize Warren Belz as our May 2025 Community…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 146,731 Most Valuable Professional

#2
RandyHayes Profile Picture

RandyHayes 76,287 Super User 2024 Season 1

#3
Pstork1 Profile Picture

Pstork1 66,075 Most Valuable Professional

Leaderboard
Loading started