PAVITRA PAVITRA - 1 year ago 77
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..

Answer Source

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

    url: "/api/Customer/GetInvoicesForCustomer", 
    method: "GET", ---> This should be post too
    data: {'element': element}
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download