I need to call a JSON API for a BPM engine from my asp.ner mvc web application . The API call to the BPM is constructed as follow:-
http://localhost:8080/jw/web/json/workflow/process/list?j_username=kermit&hash=9449B5ABCFA9AFDA36B801351ED3DF66&loginAs=' + username
where both the j_user & hash paramertes represents a master login username and password which are set at the BPM engine side. Currently i am calling the API using java/script at the view level from my asp.net mvc:-
$(document).ready(function () {
var fullurl = 'http://localhost:8080/jw/web/json/workflow/package/list?j_username=kermit&hash=9449B5ABCFA9AFDA36B801351ED3DF66&loginAs=' + username ;
$.ajax({
type: "GET",
url: fullurl,
dataType: "JSONP",
// contentType: "application/json; charset=utf-8",
success: function (result) {
$.each(result.data, function (key, val) {
// Format the text to display.
// var str = val.packageName + ' | ' + val.packageId;
var str = val.packageName ;
// Add a list item for the product.
$('<li/>', { text: str })
.appendTo($('#products'));
});
}
});
});
But i was told that exposing both the master-login username and password and also the LoginAS username which represents the username of the login user at the asp.net mvc is not secure, AND THAT I SHOULD PERFORM THE API CALL AT THE SERVER SIDE INSTEAD OF MAKING THE API CALL FROM A JAVASCRIPT.
but my question is how i can convert my above code to receive the JSON from the mvc controller side and then pass the JSON to the view? Best Regards