PAVITRA PAVITRA - 7 months ago 39
AngularJS Question

Web API sending an object to the Controller via Java Script

I'm using Angular/C# Web API.

In my JavaScript service I have the following.

invoicesForCustomer = $http.get('/api/Customer/GetInvoicesForCustomer',
{params:element} );

In the Web API Controller

public InvoiceListModel GetInvoicesForCustomer(InvoiceListOptionsModel element)

but this element object is always null. I tried this for a single parameter and it worked.
Any help on sending an object via querystring to Web API controller..


Hi Try changing [HttpGet] to [HttpPost]. Also your

    url: "/api/Customer/GetInvoicesForCustomer", 
    method: "GET", ---> This should be post too
    data: {'element': element}