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.

1 Answer 1

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.

4
  • I tried it but it doesn't work. Did this work for you ? RemoteEndpoints is required to call External Webservice. Commented Dec 9, 2015 at 6:14
  • Added update 1. Commented Dec 23, 2015 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. Commented Dec 23, 2015 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. Commented Dec 26, 2015 at 16:31

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.