SharePoint Blog

Consume your custom (SharePoint 2013 hosted) WCF Data Service in a SharePoint 2013 App

I think this will be my shortest post ever. To consume your custom (SharePoint 2013 hosted) WCF Data Service in a SharePoint 2013 App you can simply follow the instructions you find here:

Then why is this still worth a post? Simply because I think that it’s very easy to oversee this option and start digging in the wrong direction. In my case I believed that because a SharePoint hosted WCF Data Service is basically available at

hostweburl + '/_vti_bin/your_data_service_folder/your_data_service.svc'

It would be also accessible. But I found that available isn’t the equivalent of accessible. I’m still not sure whether I’m facing a flaw in my SharePoint 2013 environment or whether it really is not possible to go beyond the boundaries of the host web using SP.RequestExecutor or AppContextSite (also see my question here: But using External ContentTypes for Apps I found a quick and easy way to consume my custom (SharePoint 2013 hosted) WCF Data Service afterall.

One remark

To make things work for a WCF Data Service you may need to change the following line in the sample code

"accept": "application/json",


"accept": "application/json; odata=verbose",
  • Tudor Iliescu


    I’ve been searching for a way to call a custom SharePoint service from a SP-Hoste app for days. Can you attach a sample code?

    • Marco van Wieren

      Hi Tudor … I guess you would have two options:

      1. Consume your custom service using an external ContentType. I wrote a detailed instruction on how to get this working (incl. Secure Store for keeping credentials if passthrough isn’t working in your case):

      2. If the service is anonymous you maybe could try and use the SP.RequestExecutor for which I included an example below for calling a public Rss service (Don’t forget to add the domain the service is installed in as an allowed remote endpoint to the App’s manifest). But I haven’t tested this … It’s just a thought :)

      // Get current SharePoint context
      var context = SP.ClientContext.get_current();

      // Since we want to make a cross-domain call we need to invoke our request via the SP.WebProxy
      var request = new SP.WebRequestInfo();
      var response = SP.WebProxy.invoke(context, request);
      function () {
      // On return bind the RSS-Feed to our RSS-Template
      new RssFormatter(response.get_body(), koTemplate);

      function () {

Copyright ©2012. All Rights Reserved.