1

I want to call Rest api which is not of SharePoint. I have created one Api which is in php. And I want to call that api in my SharePoint hosted App.

Is it possible to call API which not of SharePoint in SharePoint hosted app?

Because when I tried to call API to my app it throw error : Access Denied.!.

Any suggestions..?!

2
  • You are getting access denied because of cross domain issue.
    – Aanchal
    Sep 26, 2014 at 9:18
  • Any solutions.? Is it allowed in SharePoint hosted app? Sep 26, 2014 at 9:20

1 Answer 1

2

This problem is due to the fact that SharePoint only allows out of the box REST & CSOM endpoints consumption from Apps so if you deploy custom WCF services, it won't be allowed from within the App.

If you use sp.webrequestinfo cross-domain library, you'll notice that it will work providing your service is consumable anonymously. Remember that in the context of a SharePoint-Hosted App, your only ways to consume web services are: 1. with JavaScript 2. using an External Content Type but that only works for data services and I'm not sure that it works if your service requires authentication.

So, given the above, one way to achieve our goal is to use CORS but it will require some extra efforts before it works.

For complete details check:

http://www.silver-it.com/node/159

2
  • What you have gave is the example of WCF service. And there are some solutions also available. But What I am saying is I have PHP soap api. And I want to consume it in my App. Is it possible to do so.??? And yes I have app which is SharePoint hosted app so I need to compulsory use JavaScript. Sep 26, 2014 at 9:38
  • This is just for explanation. I don't have idea about PHP soap api. You need to add above things in your API. Or simple you need to convert in your code. As dont have any idea about php, i can not say about feasibility.
    – Aanchal
    Sep 26, 2014 at 9:41

Your Answer

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

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