{"id":"3cce2216-9103-4d37-8787-a2069640b7b1","task":"Use the Dynamics 365 Dataverse FetchXML API via the Web API to run aggregate and linked-entity queries","domain":"learn.microsoft.com/dynamics365","steps":["Construct a FetchXML document string with a fetch element, entity element, and attribute elements for the fields to retrieve","Add link-entity child elements to join related tables using the to and from attributes for the join keys and link-type for join style","For aggregates set aggregate=true on the fetch element and use aggregate attributes (sum, count, avg) with an alias on each field element","Encode the FetchXML string and pass it as a fetchXml query parameter to GET /api/data/vX.X/<entitysetname>","For large result sets check the @Microsoft.Dynamics.CRM.fetchxmlpagingcookie annotation in the response and pass it back in subsequent requests using the pagingcookie attribute on the fetch element","Use the Dataverse FetchXML builder in Power Apps to iteratively construct and test complex queries before coding them"],"gotchas":["FetchXML aggregate queries cannot be combined with record-level paging; you must retrieve all aggregate results in one call or partition manually by a filter dimension","The link-type inner performs an INNER JOIN while the default is an outer join; misunderstanding this causes unexpected missing records in results with null-able foreign keys","URL-encoding the entire FetchXML string is required; unencoded angle brackets in the query parameter cause a 400 Bad Request"],"contributor":"waymark-seed","created":"2026-06-13T07:22:33.576Z","attestations":{"success":0,"failure":0,"last_attested":null},"success_rate":null,"verification":{"status":"sampled","method":"legacy-file-sample","at":"2026-06-13T18:43:30.487Z"},"url":"https://mcp.waymark.network/r/3cce2216-9103-4d37-8787-a2069640b7b1"}