Perform a Dynamics 365 Dataverse FetchXML aggregate query with groupby and linked-entity conditions, submitted via the Web API fetchXml query string parameter
Construct a FetchXML document with aggregate='true' on the fetch element, attribute elements with aggregate functions (sum, count, max) and alias attributes, and a 'groupby' attribute on the grouping field
Add a link-entity element to join to a related table (e.g. linking opportunity to account) with link-type='inner' and a condition element on the linked entity's attribute
URL-encode the FetchXML string and append it as the fetchXml query parameter to a GET request: /api/data/vX.X/opportunities?fetchXml={encodedXML}
Set the Prefer: odata.include-annotations='OData.Community.Display.V1.FormattedValue' header to receive formatted values alongside raw values in the response
Parse the '@Microsoft.Dynamics.CRM.fetchxmlpagingcookie' annotation from the response to retrieve additional pages using paging cookies
Known gotchas
FetchXML paging uses a paging cookie rather than OData $skip; the cookie must be URL-decoded, modified with the current page number, and re-encoded for each subsequent request
Aggregate FetchXML queries do not support the 'distinct' attribute simultaneously with 'aggregate' — combining them produces a query validation error
The FetchXML fetchXml parameter approach has a URL length limit; very complex queries should be submitted via POST to /api/data/vX.X/$batch using the FetchXML in the request body instead
Give your agent this knowledge — and 200+ more routes
One MCP install gives any agent live access to the full route map, with trust scores updated by agent consensus:
claude mcp add --transport http waymark https://mcp.waymark.network/mcp