I have complex object for Get WebApi from uri,
At WebApi,
Public IHttpActionresult GetData([FromUri]ComplexModel model)
{
//some code
}
public class ComplexModel
{
public int Id {get; set;}
public string name {get; set;}
}
At MVC,
Public void CallWebApi()
{
using(HttpClient client = new HttpClient())
{
var uri = baseApi + "Contoller/GetData?Id=1&name=testname";
var response = client.GetAsync(uri).Result;
}
}
Instead of passing complex object through query string, is there a better approach?