yUGfM8GV
2017-01-11 20:52:12

(window.jQuery || document.write('<script src="https:...../jquery-3.1.1.js"></script>'));
(function defer() {
if (window.jQuery) {
jQueryLoaded();
} else {
setTimeout(function() { defer() }, 50);
}
})();

function jQueryLoaded() {
$(document).ready(function () {
ExecuteOrDelayUntilScriptLoaded(function () {
var username = 'MyID';
var password = 'MyPassword';
var webServiceUrl = "http://server.domain.com:7080/this/spot";

var parm = JSON.stringify({
format: 'OBJECT',
batch: 'false',
includeColumns: 'false',
continueOnError: 'false',
logMech: 'LDAP',
spooledResultSet: 'false'
});

"use strict";

$.ajax({
url: "https://<SPsite>/_api/SP.WebProxy.invoke",
type: "POST",
data: JSON.stringify(
{
"requestInfo": {
"__metadata": { "type": "SP.WebRequestInfo" },
"Url": webServiceUrl,
"Method": "POST",
"Headers": {
"Authorization": 'Basic ' + btoa(username + ':' + password),
"results": [{
"__metadata": { "type": "SP.KeyValue" },
"Key": "Accept",
"Value": "application/json;odata=verbose",
"ValueType": "Edm.String"
}]
},
"Body": parm
}
}),
headers: {
"Accept": "application/json;odata=verbose",
"Content-Type": "application/json;odata=verbose",
"X-RequestDigest": $("#__REQUESTDIGEST").val()
},
success: function (data)
{
alert('success');
prompt("Text",JSON.stringify(data));
},
error: function (jqXHR, textStatus, errorThrown)
{
prompt("Text","Failure " + JSON.stringify(jqXHR) + " Status: " + textStatus + " Error thrown " + errorThrown);
alert("Failure " + JSON.stringify(jqXHR) + " Status: " + textStatus + " Error thrown " + errorThrown);
}
});

}, "sp.js");

});
}