Skip to main content

Notifications

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!

  • AaronLuminix Profile Picture
    10 on at
    RE: Correct way to specify RetrieveMetadataChanges through REST Web API?

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

  • Verified answer
    cloflyMao Profile Picture
    25,208 on at
    RE: Correct way to specify RetrieveMetadataChanges through REST Web API?

    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
    RE: Correct way to specify RetrieveMetadataChanges through REST Web API?

    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!

  • AaronLuminix Profile Picture
    10 on at
    RE: Correct way to specify RetrieveMetadataChanges through REST Web API?

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

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

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

🌸 Community Spring Festival 2025 Challenge Winners! 🌸

Congratulations to all our community participants!

Adis Hodzic – Community Spotlight

We are honored to recognize Adis Hodzic as our May 2025 Community…

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
Daivat Vartak (v-9davar) Profile Picture

Daivat Vartak (v-9d... 225 Super User 2025 Season 1

#2
Eugen Podkorytov Profile Picture

Eugen Podkorytov 106

#2
Muhammad Shahzad Shafique Profile Picture

Muhammad Shahzad Sh... 106 Most Valuable Professional

Overall leaderboard

Product updates

Dynamics 365 release plans