I am trying to execute fetch XML using WEB API /api/data/v8.x. All is fine except when I have query involving "where a attribute contains number value". For example, the following fetchXML to find account with 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 via GET on 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>
CRM Web API returns Invalid XML error as follows:
{ "error":{ "code":"","message":"Invalid XML.","innererror":{ "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 run alright if the filter value does not start with number or I remove the '%' on the filter value. My conclusion is this is having to do with encoding and decoding "% + number" in my filter value.
Is there anything wrong with my query or is this Dynamics CRM Web API bug? any work around?
value='%3'
for example. Neithervalue='%03%'
norvalue='%30%'
works. – dynamicallyCRM