Hello Expert,
The following fetchXml below code.
var apiQuery = myurl/api/data/v8.2/+ reviews";
var fetchXML = '<fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="false" aggregate="true">' +
'<entity name="review">' +
'<filter type="and">' +
'<condition attribute="score" operator="ge" value="10" />' +
'<condition attribute="reviewid" operator="eq" uitype="review" value="' + reviewID.replace('{', '').replace('}', '') + '" />' +
'</filter>' +
'<link-entity name="reviewsection" from="review" to="reviewid" link-type="inner" alias="ac">' +
'<link-entity name="action" from="reviewsection" to="reviewsectionid" link-type="inner" alias="ad">' +
'<attribute name="agendaitem" alias="cntAgenda" aggregate="count" />' +
'<attribute name="commitment" alias="cntCommitment" aggregate="count" />' +
'</link-entity>' +
'</link-entity>' +
'</entity>' +
'</fetch >';
var encodedFetchXML = encodeURIComponent(fetchXML);
var results;
var req = new XMLHttpRequest();
req.open("GET", apiQuery + "?fetchXml=" + encodedFetchXML, false);
req.setRequestHeader("OData-MaxVersion", "4.0");
req.setRequestHeader("OData-Version", "4.0");
req.setRequestHeader("Accept", "application/json");
req.setRequestHeader("Prefer", "odata.include-annotations=\"OData.Community.Display.V1.FormattedValue\"");
req.onreadystatechange = function () {
if (this.readyState === 4) {
req.onreadystatechange = null;
if (this.status === 200) {
results = JSON.parse(this.responseText);
if (!isNullOrUndefined(results) && results.value.length > 0) {
results = results.value;
}
}
}
};
req.send();
return results;
I'm porting all the scripts to use WebAPI. When the same fetchxml is executed against WebAPI, I get this error message:
"The property provided was of type System.Int32, when the expected was of type Microsoft.Xrm.Sdk.EntityReference" and also I got this. status=400 instead of this.status =200.
Anyone had the same problem?
Thanks






