I've made some updates based on the responses provided. My main area of confusion lies in the 'data' parameter and how to handle it in the JavaScript call.
C# method
[HttpPost]
public string GetPreviewURL(string activityID)
{
try
{
var requestContext = ContextHandler.GetRequestContext(Request);
object[] arguments = new object[] { requestContext };
var sew= SumtContainer.Resolve<ICLWOrker>(typeof(ICLWOrker).FullName, arguments);
return sew.GetPreviewUrl(activityID);
}
catch (Exception e)
}
When making this JS call, I believe the parameter after "POST" should be 'data', but I'm unsure about extracting the URL from the JSON data.
apiAccessClient = new apiClient();
var apiUrl = STRING_SITE_PREFIX + '/service/webapi/GetPreviewURL/?activityID=' + actId;
//How do I define 'data' here?
apiAccessClient.send(STRING_USERMODE, apiUrl, "POST", data, onPreviewSuccess, onError, 0, null, false, false, true);
return;
The setup for apiAccessClient is currently in a separate JavaScript file where the Ajax call is configured
$.ajax({
type: this.requestType,
url: this.apiUrl,
contentType: "application/json; charset=utf-8",
context: this,
async: isAsync,
data: JSON.stringify(flattenModel(this.parameters)),
statusCode: {
401: function () { _UTL_NavigateToTimeOutPage(); }
},
beforeSend: function (request) {
// Set headers here
},
success: function (data, statusCode, jqXHR) {
// Handle success response
},
error: function (jqXHR, textStatus, errorThrown) {
// Handle error response
}
});
Could someone provide guidance on how to open the URL received in a new window?
Appreciate your assistance!