4 comments on “Accessing Metadata Service on CRM 2011 with REST

  1. I would also suggest adding in the “RetrieveAsIfPublished” flag which is only valid post update rollup 5. However, this will significantly decrease the amount of time it takes each request to execute.

    Like

  2. Adding some additional information: seanmcne says:
    I would also suggest adding in the “RetrieveAsIfPublished” flag which is only valid post update rollup 5. However, this will significantly decrease the amount of time it takes each request to execute. Passing in a value of False will only retrieve the inProduction metadata (which is also cached by CRM) making the call much quicker, if you pass in True you will be retrieving the metadata as if it ‘is’ published which would include pending changes to metadata.

    Like

  3. —————————
    Message from webpage
    —————————
    Error : error: Unsupported Media Type

    Code :

    Message : Unsupported media type requested.
    —————————
    OK
    —————————

    Could this be a rollup 13 issue?

    snippet follows

    var serverUrl = Xrm.Page.context.getClientUrl();

    //The XRM OData end-point
    var METADATA_ENDPOINT = “/XRMServices/2011/OrganizationData.svc”;

    //Build the URI
    var metadataUri = serverUrl + METADATA_ENDPOINT + “/” + “$metadata”;

    // default settings
    var settings = {
    type: “GET”,
    async: false,
    url: metadataUri,
    contentType: “application/json; charset=utf-8”,
    datatype: “json”,
    beforeSend: function (request) {
    request.setRequestHeader(“Accept”, “application/json”);
    },
    error: function (XmlHttpRequest, textStatus, errorThrown) {
    var error = window.JSON.parse(XmlHttpRequest.responseText);
    alert(“Error : ” + textStatus + “: ” + XmlHttpRequest.statusText +
    “\r\nCode : ” + error.error.code +
    “\r\nMessage : ” + error.error.message.value);
    }
    };

    var result = $.ajax(settings).responseText;

    Like

  4. Hey Mark,

    This is an old post when there was no web endpoint for organization service. But I think by rollup 3 or 4 there is a web endpoint to which you can make soap calls to (…/organization.svc/web). I think you can even find a sample in the Dynamics Crm SDK to load entities and their attributes. (sdk\samplecode\js\soapforjscript\soapforjscript\scripts\sdk.metadata.js)

    I think it is about time I updated this post, sorry for misleading you.

    Can

    Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s