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.
You can mix Web API and MVC controller in a single project to handle advanced AJAX requests which may return data in JSON, XML or any others format and building a full-blown HTTP service. Typically, this will be called Web API self-hosting.
Best way to pass multiple complex object to webapi services is by using tuple other than dynamic, json string, custom class. No need to serialize and deserialize passing object while using tuple. If you want to send more than seven complex object create internal tuple object for last tuple argument.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With