REST / AJAX calls from within a Jaggery script




<%
var mySecureToken = FnMakeRequestCall("https://10.299.99.99:8245/token","POST","Basic RlN4S2RrZEpNN3VaYWhHN0NFcEtlaTZEa3RzYTpXbmUxd29seHp2UTNSQ2RZbXhUUTJ2WkJTd0Fh","application/x-www-form-urlencoded; charset=UTF-8",""application/json; charset=utf-8","grant_type=password&username=pcsadmin&password=pcsadmin");


 print(mySecureToken);
function FnMakeRequestCall(URL, METHOD, BASICAUTH, CONTENTTYPE, ACCEPTTYPE, INPUTDATA){
if(BASICAUTH){
//var VarBasicAuthCode = util.FnCreateBasicAuthentication(VARSKYSPARKUSERNAME,VARSKYSPARKPASSWORD);
var VarBasicAuthCode = session.get('authToken');
}
xhr = new XMLHttpRequest();
xhr.open(METHOD, URL);
if(BASICAUTH){
xhr.setRequestHeader("Authorization" , VarBasicAuthCode);
}
xhr.setRequestHeader("Content-Type", CONTENTTYPE);
xhr.setRequestHeader("Accept", ACCEPTTYPE);
xhr.send(INPUTDATA);
var VarResponse = xhr.responseText;
return VarResponse;
}

%>

Comments

Popular posts from this blog

உடல் அறிகுறிகள், வலிகள் மற்றும் அவற்றின் சிகிச்சைகள்: வீட்டு சிகிச்சைகள் மற்றும் அக்குபிரஷர் புள்ளிகள்

MySQL table and want to build a XML file with it in order to make a RSS feed.