Skip to content

Instantly share code, notes, and snippets.

@peta
Last active October 30, 2018 09:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save peta/49a70a32a31ea186697bacb33ba46fc7 to your computer and use it in GitHub Desktop.
Save peta/49a70a32a31ea186697bacb33ba46fc7 to your computer and use it in GitHub Desktop.
Testcase: Bug in Dynamics CRM Web API (OData 4.x) for RetrieveMultiple by FetchXML

Description

While migrating some form logic which used to execute a FetchXML query and react to the result accordingly, from XrmServiceToolkit to the native OData Web API in 8.2, I encountered some weird platform behaviour. Everytime the LIKE filter condition contained a part of the number series 123456789 beginning at number 1 (like for example %123%), the OData service yields a 500 server error for no obvious reason.

Outcome

This bug was solved in latest 9.1 version (or earlier), event in the Web API endpoint version 8.1

Steps to reproduce

  1. Build FetchXML query which contains a LIKE filter with an arbitrary substring of the number series 123456789 beginning at first digit
  2. Send a RetrieveMultiple request using previously created FetchXML query to Web API
<fetch top="50" >
<entity name="account" >
<attribute name="accountnumber" />
<filter>
<condition attribute="accountnumber" operator="like" value="%123%" />
</filter>
</entity>
</fetch>
var req = new XMLHttpRequest();
req.open("GET", Xrm.Page.context.getClientUrl() + "/api/data/v8.1/accounts?fetchXml=%3Cfetch%20top%3D%2250%22%20%3E%3Centity%20name%3D%22account%22%20%3E%3Cattribute%20name%3D%22accountnumber%22%20%2F%3E%3Cfilter%3E%3Ccondition%20attribute%3D%22accountnumber%22%20operator%3D%22like%22%20value%3D%22%25123%25%22%20%2F%3E%3C%2Ffilter%3E%3C%2Fentity%3E%3C%2Ffetch%3E", true);
req.setRequestHeader("OData-MaxVersion", "4.0");
req.setRequestHeader("OData-Version", "4.0");
req.setRequestHeader("Accept", "application/json");
req.setRequestHeader("Prefer", "odata.include-annotations=\"*\"");
req.onreadystatechange = function() {
if (this.readyState === 4) {
req.onreadystatechange = null;
if (this.status === 200) {
var results = JSON.parse(this.response);
} else {
Xrm.Utility.alertDialog(this.statusText);
}
}
};
req.send();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment