2

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?

Romeo
  • 1,791
  • 8
  • 25
  • 41
  • 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 Jan 29 '15 at 09:49
  • 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 Jan 29 '15 at 09:53
  • possible duplicate of [Access MS CRM Web Services From External App/Javascript](http://stackoverflow.com/questions/4937117/access-ms-crm-web-services-from-external-app-javascript) – Alex Jan 29 '15 at 14:55

1 Answers1

3

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.

Community
  • 1
  • 1
Thangadurai
  • 2,573
  • 26
  • 32
  • 1
    @Alex, yes that is a copy paste, that's why I have included the original post also. Why that needs a down vote? An answer is an "answer" it doesn't matter whether its a copy paste or "typed" just by different words or rearranging the words. – Thangadurai Jan 30 '15 at 06:06
  • 3
    stackoverflow is getting more disappointing everyday because of these moderators. They're only concern is to improve their reputation rather than helping other people. grow up people. never forget stackoverflow is built to make a community that will help each other, not compete with other people. – Romeo Feb 01 '15 at 07:17