I'm running an API in C# and started it as default webapi, so it gets the /api/<controller>
url.
In my controller, I'm using GET
method to retrieve some chart objects trough a switch case, but when testing on POSTMAN, both params work, but I get only the first object, and I can't seem to figure out why
Here's my controller
public class GraphController : ApiController
{
public Graph Get(string param)
{
//string[] arrayListGraphic = param.Split('|');
switch (param)
{
// case "GF001": return new GraphDAO().graph01();
case "GF002": return new GraphDAO().graph02();
case "GF003": return new GraphDAO().graph03();
// case "GF004": return new GraphDAO().graph04();
// case "GF005": return new GraphDAO().graph04();
// case "GF006": return new GraphDAO().graph01();
}
return null;
}
}
so, the request comes as localhost:xxxx/api/graph/?param=GF002¶m=GF003
, But my response only gets me the first parameter data, when I wish to get all the parameters data!
What am I missing? Thanks
param
look like when you pass it two values in the query string (?param=GF002¶m=GF003
). Even if it came in as a collection ofGF002
andGF003
, then what? You'd need to loop over them, and then return the two graphs somehow. Consider changing your API so that your query string looks something like?param=GF002+GF003
(or use some other separator). – Flydog57 Feb 12 at 19:18