I have an MVC Web API Get method that accepts a List<string>
as a parameter. I'm trying to access this method using simply the browser bar. How is this done? Using ../APIName?parameter1=value1¶meter2=value2&...
passes a single parameter between two ampersands as opposed to a list.
Asked
Active
Viewed 1.8k times
24
1 Answers
40
Make sure your parameter of your action method is marked as [FromUri]. By default the value is expected to be passed from the body of the request since it is a complex type.
public List<string> Get([FromUri] List<string> parameter) {...}
The query string parameter should be of this format
.../APIName?parameter[]=value1¶meter[]=value2&...
.
Hope this helps.

Maggie Ying
- 10,095
- 2
- 33
- 36
-
2Thank you for this answer, it did help. The square brackets "[]" were unnecessary for me. – Onosa Jun 03 '14 at 17:26
-
This isn't working for me. It works with the first 'parameter' call (with or without square brackets), but as soon as I add the second I just get a 500 message back from the server with no additional info, and no breakpoint hit in VS – Chris Surfleet Feb 18 '16 at 14:35
-
@ChrisSurfleet - too late to reply but are you sure you added List
and not just string as the parameter type. – sandiejat Mar 20 '17 at 02:32