2
votes

I'm trying to access Dynamics CRM OData using AngularJS but I'm not sure where to set my credentials. I'm getting a 401 (Unauthorized) error with this code:

angularDynamicsCRM.factory('DynamicsCRMService', function ($resource) { var oDataUrl = Xrm.Page.context.getClientUrl() + '/XRMServices/2011/OrganizationData.svc/';

var defaultParams = {};

/// describe our API actions
var actions = {
    lookup: {
        method: 'GET',
        url: oDataUrl + ':entitySet?$filter=startswith(:field, \':search\')',
        withCredentials: true

    }
};

/// create the service
return $resource(oDataUrl, defaultParams, actions); });

How can I set my CRM credentials when accessing the OData using this code?

1
Is it a HTML resource file with the script, that is added to the CRM Forms? or you are accessing it from some external application like ASP.NET or MVC, etc.?Thangadurai
I'm accessing it through an external application but not ASP.Net nor MVC. Im just using Angular JS and Html for this application.Romeo

1 Answers

3
votes

As per Microsoft definition "Dynamics CRM does not permit authentication from external applications."

However, a Web resource such as a Silverlight XAP file or a JavaScript file that is hosted in a Dynamics CRM solution can use the OData service as a data source

There is already a question in SO here. See the accepted answer.