Quantcast
Channel: Developing Apps for SharePoint 2013 forum
Viewing all articles
Browse latest Browse all 8089

Calls to WebProxy without an app context are not allowed.

$
0
0

From SharePoint 2013's default.aspx page (https://somecompany-public.sharepoint.com/pages/default.aspx) I'm trying to call a RESTful json API which lives outside the SharePoint domain, but getting an error "Calls to WebProxy without an app context are not allowed."

Do I need to create an app to access the API which lives outside SharePoint? 

Here is how I'm trying:

<script language="javascript">

var responseDocument = undefined;

function onSuccess() {
    var response = responseDocument.get_body();
    alert('success ' + response);//this line gives the error in my question
}

function onError(err) {
    alert(JSON.stringify(err));
}

$(function () {
    var ctx = SP.ClientContext.get_current();
    var request = new SP.WebRequestInfo();
    request.set_url('https://api.somedomain.com/data/10001');
    request.set_method("GET");
    responseDocument = SP.WebProxy.invoke(ctx, request); // executes on sp server
    ctx.executeQueryAsync(onSuccess, onError);
});

</script>



Viewing all articles
Browse latest Browse all 8089

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>