I am trying to fetch XML using WEB API / api / data / v8.x. Everything is fine if I have a query that includes "where the attribute contains a numeric value." For example, the following fetchXML file to search for an account with a phone number contains β03β:
<fetch mapping="logical"> <entity name="account"> <attribute name="name" /> <attribute name="telephone1" /> <order attribute="name" descending="false" /> <filter type="and"> <condition attribute="telephone1" operator="like" value="%03%" /> </filter> </entity> </fetch>
When we run it through the GET on the WEB API:
https://CRM_URL/api/data/v8.0/accounts?fetchXml=<fetch%20mapping%3D"logical"><entity%20name%3D"account"><attribute%20name%3D"name"%20%2F><attribute%20name%3D"telephone1"%20%2F><order%20attribute%3D"name"%20descending%3D"false"%20%2F><filter%20type%3D"and"><condition%20attribute%3D"telephone1"%20operator%3D"like"%20value%3D"%2503%25"%20%2F><%2Ffilter><%2Fentity><%2Ffetch>
The CRM Web API returns an invalid XML error as follows:
{"error": {"code": "," message ":" Invalid XML. "," internalerror ": {" message ":" Invalid XML. "," type ":" System.ServiceModel.FaultException`1 [[Microsoft.Xrm.Sdk.OrganizationServiceFault, Microsoft.Xrm.Sdk, Version = 8.0.0.0, Culture = neutral, PublicKeyToken = 31bf3856ad364e35]] "}}}
The query is executed normally if the filter value does not start with a number or I delete "%" in the filter value. My conclusion is that this is due to the encoding and decoding of "% + number" in my filter value.
Is there something wrong with my request or is it a Dynamics CRM API error? any work around?
Felix source share