I've been testing an outgoing REST GET request (towards the other world, not towards SharePoint).
When I'm using this code in pure JavaScript/HTML it works just fine. But when using it in my SharePoint app I'm receiving a JavaScript runtime error:
NetworkError at client.send(null);
This is the code I've tried so far:
var url = "https://test.com/example/something/1";
var client = new XMLHttpRequest();
client.open("GET", url, false);
client.setRequestHeader("Content-Type", "application/json");
client.setRequestHeader("theplatform", "default");
client.setRequestHeader("Authorization", "Basic keyofsomethingvalue%");
client.send(null);
if (client.status == 200)
alert("The request succeeded!\n\nThe response representation was:\n\n" + client.responseText)
else
alert("The request did not succeed!\n\nThe response status was: " + client.status + " " + client.statusText + ".");
Does anybody know what I did wrong?