2

I have created a SharePoint Hosted App and wanted to get response from some external webservice.

I am able to get the response in SharePoint Hosted App's default.aspx but says

FORBIDDEN

when it is executed from ClientWebPart!

For code reference - https://msdn.microsoft.com/en-us/library/office/fp179895.aspx.

I used exactly the same code and tried with JSOM and REST both, but no hope. I am getting the same error with Northwind.svc also.

0

Probably you didn't add the service server to the AppManifest.xml endpoints section.

<RemoteEndpoints>
    <RemoteEndpoint Url=" http://services.odata.org" />
</RemoteEndpoints>

UPDATE 1: I can't test the MSDN example today, but I was succeded in calling to an external WebService from JS Code in my SharePoint-hosted app. This app works well in production for about half a year. I will try to show here a piece of code which works for me tomorrow.

For a while you can try to troubleshoot it using Fiddler to understand what happens behind the scenes. Probably, it will get you some ideas.

  • I tried it but it doesn't work. Did this work for you ? RemoteEndpoints is required to call External Webservice. – Azam Khan Dec 9 '15 at 6:14
  • Added update 1. – MikhailSP Dec 23 '15 at 16:34
  • I am not sure why this answer is voted down. We are making external calls from our addin and this is exactly what we do i.e. add the service Url to remote endpoints. – Prakash - Crow Canyon Dec 23 '15 at 16:50
  • @Prakash-CrowCanyon You are right Prakash, Service URL has to be added in RemoteEndPoints. But it answer it is mentioned that it shouldn't be added. Are you able to to retrieve data in ClientWebPart ?. For me it works only in default.aspx and gives "FORBIDDEN" in ClientWebPart. – Azam Khan Dec 26 '15 at 16:31

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.