Incorporating both angularjs and c# webapi in this situation.
My approach involves calling the webapi from angularjs and passing a json array.
Here is the Angularjs code snippet:
factory.delete = function (json) {
var url = 'myUrl';
return $http.post(url, json).then(function (res) {
return res;
}, function (err) {
throw err;
});
}
As for the C# Api:
[HttpPost("data/delete")]
public async Task<IActionResult> DeleteData([FromBody] List<UserEntity>
jsonData)
{
//Perform deletion logic here based on the json data
}
I'm questioning if my method of using post instead of httpdelete for deleting is correct. So far, the above method works successfully
An attempt was made to use http delete as shown below:
factory.delete = function (ids) {
var url = 'myUrl';
return $http.delete(url, ids).then(function (res) {
return res;
}, function (err) {
throw err;
});
}
[HttpDelete("data/{ids}/delete")]
public async Task<IActionResult> DeleteData(string ids)
{
//Within this method, ids are expected to be comma separated and each ID will be deleted individually
}
However, I am facing an issue with the ids parameter being null within the API. Any insights or suggestions would be greatly appreciated.