I want to pass multiple objects and a value from angular to asp .net web Api.
My js:
var productStockArray =$scope.ProductStockArray;
var challan = 20;
$http.post(dataUrl + "StockProductApi/InsertStockdata", { params: { ProductStockArray: productStockArray, Challan: challan } })
.then(function (data) {
Here productStockArray
is like given below: and callan is single value
{ProductCode: "Pr- 001", ProductName: "T-Shirt", DealerPrice: 5, profitPercentage: 5, freePc: 5}
{ProductCode: "abc6", ProductName: "Luxs", originalPc: 455, freePc: 5, profitPercentage: 5}
My WebApi:
[HttpPost]
[Route("api/StockProductApi/InsertStockdata/")]
public HttpResponseMessage InsertStockdata(IEnumerable<StockProduct> ProductStockArray, int Challan)
{
---------
}
N.B: whole code is avoided for brevity.
if i pass only one parameter (objects) in angular and webapi, it ok. but when i want to pass two parameters (objects and int), it shows not found error in console. if i pass two parameters (int and int), it ok. My question is can't i pass parameters (objects and int) to web api using angular http.post method?
i can get one parameter(only objects). But i want to pass 2 parameter (objects and int) to web api. How can i do this?