I am trying to build an API with 1 string and 5 arrays as parameters:
public List<HomeClass> GetData(string id, string[] price, string[] type, string[] sqft, string[] beds, string[] baths)
{
}
I am using jQuery to call this API like so:
var priceArray = [];
var typeArray = [];
var sqftArray = [];
var bedroomsArray = [];
var bathroomsArray = [];
function searchInventory(community, price, type, sqft, bedrooms, bathrooms) {
$.get('/api/HomesAPI/' + community + '/' + price + '/' + type + '/' + sqft + '/' + bedrooms + '/' + bathrooms).then(function (result) {
});
}
searchInventory(getURLParameter(window.location.pathname.split('/'))[2], priceArray, typeArray, sqftArray, bedroomsArray, bathroomsArray);
So I am passing 1 string and 5 arrays, but my API is not being called, if I change the array to strings in both .NET and jQuery, it works just fine, but not with arrays. What am I doing wrong?
Here is my route
config.Routes.MapHttpRoute(
name: "DefaultApi",
routeTemplate: "api/{controller}/{id}/{price}/{type}/{sqft}/{beds}/{baths}",
defaults: new { id = RouteParameter.Optional }
);