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?

3
  • 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.? Commented Jan 29, 2015 at 9: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. Commented Jan 29, 2015 at 9:53
  • possible duplicate of Access MS CRM Web Services From External App/Javascript Commented Jan 29, 2015 at 14:55

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

2 Comments

@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.
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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.