I have custom service deployed on sharepoint farm site collection, and I want to consume it in a external angularJs app, I use this script

$http.get("url").success(function (data) {
        console.log('get Success');
    }).error(function (data) {
        console.log('get Error');

and I get the following error in the internet browser console.

IE :

SCRIPT7002: XMLHttpRequest: Network Error 0x80070005, Access is denied.

Google chrome:

XMLHttpRequest cannot load "service url" The 'Access-Control-Allow-Origin' header has a value 'site url' that is not equal to the supplied origin. Origin 'angularjs site url' is therefore not allowed access.


Angular and jQuery will not let you do this. Its to do with Cross Domain queries.

If you are going to write apps that are not local to SharePoint you will still need them to run on a trusted App server to SharePoint and you will have to use the JSOM calls.

Research Provider Hosted Apps, all the evil involved in configuring the servers and the trust relationships.

Here is an example of using Cross Doamin calls (in jQuery, but if you can code in angular then you can easily convert it) http://msdn.microsoft.com/en-us/library/fp179927.aspx

-- Update. Some days I am such an idiot, I even blogged on how to do this.

If your data is in SharePoint lists then you dont need X-Domain queries, of course. If your data is not in sharepoint lists but on other services, like yahoo or whatever, then SharePoint has a built in mechanism to do this, the SP.WebProxy, it will relay x-domain queries for you, you have to remember to put it into the App Manifest, list the remote URLS you are connecting to so that it becomes trusted, but then the code is as my blog article.


In the comment, regarding is it best practice, well I can't answer that one it's a IT pro question really, but using this technique, you can avoid any "voodoo" you might be doing here, and host the services disconnected from SP.

| improve this answer | |
  • I figured that out, so now I develop the frontend angularjs on site, and the wcf on another, and both are running in the same sharepoint application pool, it's work but I'm not sure if it is an good approach or not? – Mahde Abdnabi Sep 4 '14 at 9:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.