I am trying to understand how to craft a RetrieveMetadataChanges query via the Web API (REST). The following GET url for our org appears to parse correctly:
":">MYORG.crm.dynamics.com/.../RetrieveMetadataChanges(Query={"Criteria": {"Conditions":[ {"PropertyName":"LogicalName", "ConditionOperator":"eq", "Value":{"Type": "Edm.String", "Value":"account"}} ] }})
But I get the following error as a response:
"Invalid JSON. A token was not recognized in the JSON content."
I have verified that the JSON specified for the Query= argument parses correctly (using a separate validator), so it is well-formed JSON.
Thanks in advance!
Yes, System.String fixes the query, thank you!
Hi Aaron,
It seems that Type should be System.String instead of Edm.String.
Result:
Javascript ajax version:
var json = { 'Criteria': { 'Conditions': [{ 'PropertyName': 'LogicalName', 'ConditionOperator': '0', 'Value': { 'Type': 'System.String', 'Value': 'account' } }] } } var req = new XMLHttpRequest(); req.open("GET", Xrm.Page.context.getClientUrl() "/api/data/v9.1/RetrieveMetadataChanges(Query=@p1)?@p1=" JSON.stringify(json), true); req.setRequestHeader("OData-MaxVersion", "4.0"); req.setRequestHeader("OData-Version", "4.0"); req.setRequestHeader("Accept", "application/json"); req.setRequestHeader("Content-Type", "application/json; charset=utf-8"); req.onreadystatechange = function() { if (this.readyState === 4) { req.onreadystatechange = null; if (this.status === 200) { var results = JSON.parse(this.response); console.log(results); } else { alert(this.response); } } }; req.send();
Regards,
Clofly
I have gotten a little further with this url:
ourorg.crm.dynamics.com/api/data/v9.0/RetrieveMetadataChanges(Query=@p1)?@p1={"Criteria": {"Conditions":[ {"PropertyName":"LogicalName", "ConditionOperator":"0", "Value":{"Type": "Edm.String", "Value":"account"}} ] }}
The error and backtrace from the server is now:
"Value cannot be null.\r\nParameter name: conversionType"
" at System.Convert.ChangeType(Object value, Type conversionType, IFormatProvider provider)\r\n at Microsoft.Crm.Extensibility.OData.TypeConverters.EdmComplexTypeConverter.ConvertToCrmTypeInternal(EdmComplexObject edmTypeValue, String operationName)\r\n [...]"
If I change the {"Type": "Edm.String", "Value":"account"} argument to just simply null , the query then succeeds (but is useless data). So I know that the error is somehow in the JSON specification of the Microsoft.Dynamics.CRM.Object.
Does anyone know how to correctly craft this request? Any pointers to overlooked documentation would be appreciated!
OOPS, the posted url got rewritten somehow, this was the original (without https)
ourorg.crm.dynamics.com/api/data/v9.0/RetrieveMetadataChanges(Query={"Criteria": {"Conditions":[ {"PropertyName":"LogicalName", "ConditionOperator":"eq", "Value":{"Type": "Edm.String", "Value":"account"}} ] }})
Daivat Vartak (v-9d...
225
Super User 2025 Season 1
Eugen Podkorytov
106
Muhammad Shahzad Sh...
106
Most Valuable Professional