Reputation: 27
I have the following controller to take four parameter and one to get an array of string.
public Response Get(string a, double b, double c, string[] d)
{
do something
}
As u see the fourth(d) parameter is an array of strings. The first 3 parameter get the value but d shows null.
I am using fiddler to debug with following url
04/api/Controller?a=Hello&b=-37.8031231&c=144.9836514&d=Italian&d=bars
What m i doing wrong? is it the url?
Upvotes: 2
Views: 3811
Reputation: 129
You can post array data from fiddler, the URL you have provided is correct. But make sure you have the correct content type in request header.
you don't have to create view to test your controller action method.
Client request
Server respone
P.S. Above provided is for controller action method, I have noticed you are using api controller after posting the answer. I will edit the answer once done for api controller.
The Above works for APIController as well, If you are posting from fiddler
Upvotes: 1
Reputation: 32500
Without seeing your View, I can abstract that you named 2 inputs as name='d' without indexing
example:
You can create an array by naming your id inputs with array indexes.
@using (Html.BeginForm())
{
<input type="text" name="d[1]">
<input type="text" name="d[2]">
}
If you index your inputs, the framework will use them as a List
Note: you bring up URL. You cannot pass an array or any complex object without a Post.
Upvotes: 1