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

Community site session details

Session Id :
Power Pages - Power Apps Portals
Suggested answer

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

(1) ShareShare
ReportReport
Posted on by 30
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:
I have the same question (0)
  • Suggested answer
    Fubar Profile Picture
    8,112 Super User 2025 Season 2 on at
    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
    30 on at
    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
    632 Super User 2025 Season 2 on at
    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

Responsible AI policies

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

MS.Ragavendar – Community Spotlight

We are honored to recognize Ragavendar Swaminatha Subramanian as our September…

Leaderboard > Power Pages

#1
Jon Unzueta Profile Picture

Jon Unzueta 100 Super User 2025 Season 2

#2
Shafiuddin Profile Picture

Shafiuddin 45

#3
Fubar Profile Picture

Fubar 36 Super User 2025 Season 2

Last 30 days Overall leaderboard