1
In my application I created a C#API, which is consumed by my web application in Angular. I need to pass 1 object and 1 vector as parameters to the API, but the content arrives empty in the API, how to solve?
Follow below my codes:
Javascript part:
$scope.Exportar = function () {
var listProdutos = {
ListaCompraVenda : {listacompravenda: $scope.modelcompraevenda.listProdutos},
ListaMeses : {meses:[$scope.dataBase.data1,
$scope.dataBase.data2,
$scope.dataBase.data3,
$scope.dataBase.data4,
$scope.dataBase.data5,
$scope.dataBase.data6,
$scope.dataBase.data7,
$scope.dataBase.data8,
$scope.dataBase.data9,
$scope.dataBase.data10,
$scope.dataBase.data11,
$scope.dataBase.data12]}
};
$http.post($rootScope.raiz_ws + "/local/funcao", listProdutos )
.then(function (response) {
});
};
Controller in C#
[HttpPost]
[Route("funcao")]
public HttpResponseMessage Gerar(Classe listProdutos)
{..}
Class in C#:
public class Classe
{
public List<CompraeVenda> ListaCompraVenda { get; set; }
public List<string> ListaMeses { get; set; }
}
Even using [Frombody], Listacompra Venda and Listameses comes with null value.
– Welber Silverio