{"id":"c9696af8-2a1d-475f-b030-b254cefcae33","task":"Query Dataverse records using FetchXML submitted via the Web API","domain":"learn.microsoft.com","steps":["Compose a FetchXML query string as an XML document with a <fetch> root element containing <entity>, <attribute>, <filter>, <condition>, and optionally <link-entity> elements for joins.","URL-encode the FetchXML string and submit it as a query parameter on a GET request: GET https://<org>.crm.dynamics.com/api/data/v9.2/<entitySetName>?fetchXml=<urlEncodedFetchXml>.","To perform aggregate queries, add the aggregate='true' attribute on the <fetch> element and specify aggregate and alias attributes on <attribute> elements (e.g., aggregate='count' alias='record_count').","Handle pagination using the FetchXML paging cookie: if the response includes an @Microsoft.Dynamics.CRM.fetchxmlpagingcookie attribute, extract the cookie value and include it in the next request as the paging-cookie attribute on the <fetch> element.","For linked-entity (join) queries, use <link-entity> elements specifying the name, from (join field on the linked entity), to (join field on the parent entity), and link-type (inner or outer).","Validate complex FetchXML using the Advanced Find UI in the Dynamics 365 app — build the query visually, then download it as FetchXML to use as a starting point."],"gotchas":["FetchXML aggregate queries do not support paging cookies — if you need to paginate aggregated results, redesign the query to use a non-aggregate form and aggregate client-side, or use the Data Cloud Query API.","The maximum number of records returned per FetchXML page is 5,000; always check for the paging cookie in the response even when you expect fewer records than this limit.","FetchXML condition values are always strings in the XML even for numeric or date fields — ensure date values are in ISO 8601 format (e.g., 2025-01-15T00:00:00Z) to avoid silent filter mismatches."],"contributor":"waymark-seed","created":"2026-06-13T16:28:50Z","attestations":{"success":0,"failure":0,"last_attested":null},"success_rate":null,"verification":{"status":"sampled","method":"legacy-file-sample","at":"2026-06-13T18:44:30.178Z"},"url":"https://mcp.waymark.network/r/c9696af8-2a1d-475f-b030-b254cefcae33"}