I use javascript in my webpage to send a GUID (url parameter) + a GUID array to the webservice. But when I try to send the GUID array, the parameter stays everytime empty.
my Javascript looks like this:
//Save Button is clicked
function saveBtnClicked() {
var currentDataSetGuid = $("#currentDataSetGuid").val();
var Table = $("#Table").find("tbody").first();
var selectedElements = Table.find("input:checked");
var saveGuidArray = new Array();
var i = 0;
while (i < selectedElements.length) {
var trid = selectedElements[i].parentElement.parentElement.id;
saveGuidArray.push(trid);
i = i + 1;
}
putSave(currentDataSetGuid,saveGuidArray)
}
//Save action to call the controller
function putSave(currentDataSetGuid, saveGuidArray) {
$.ajax({
dataType: "json",
cache: false,
method: "PUT",
url: "/api/myAPP/SaveEndpoint/" + currentDataSetGuid,
contentType: "application/json",
data: JSON.stringify({ paramName: saveGuidArray}),
success: function (result) {
showSuccess("Save was successfull");
},
error: function (error) {
showError("Error while saving");
}
});
}
I also tried - but with the same result:
data: JSON.stringify(saveGuidArray),
And here is my implementation of the Controller Interface (C#)
[HttpPut]
[Route("/api/myAPP/SaveEndpoint/{currentDataSetGuid}")]
public IActionResult SaveAction(Guid currentDataSetGuid, List<Guid> saveGuidArray)
In my controller, currentDataSetGuid is set every time correctly. But saveGuidArray is empty / has no elements.