web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Customer experience | Sales, Customer Insights,...
Answered

Correct way to specify RetrieveMetadataChanges through REST Web API?

(0) ShareShare
ReportReport
Posted on by 10

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.

  • Does anyone know what is wrong with the query as crafted above?
  • Note that I am not interested in solutions that require the Organization Service (e.g., Microsoft.CrmSdk.CoreAssemblies).
  • Are there examples for how to craft the RetrieveMetadataChanges through the Web API (REST)?

Thanks in advance!

I have the same question (0)
  • AaronLuminix Profile Picture
    10 on at

    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"}} ] }})

  • AaronLuminix Profile Picture
    10 on at

    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!

  • Verified answer
    cloflyMao Profile Picture
    25,210 on at

    Hi Aaron,

    It seems that Type should be System.String instead of Edm.String.

    Result:

    pastedimage1583205823937v1.png

    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

  • AaronLuminix Profile Picture
    10 on at

    Yes, System.String fixes the query, thank you!

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
Tom_Gioielli Profile Picture

Tom_Gioielli 70 Super User 2025 Season 2

#2
Gerardo Rentería García Profile Picture

Gerardo Rentería Ga... 33 Most Valuable Professional

#3
Daniyal Khaleel Profile Picture

Daniyal Khaleel 32 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans