Reputation: 5162
I am converting some of my services to Web API2 and I have some functions which take 2 or 3 parameters. How are those routing attributes constructed?
When I call the function from the old service in javascript its
data: { "symboltype": symboltype, "symbol": symb, "requestDate": dDate}
I've tried the following routing attribute among other variations, which dont work
<HttpGet()> _
<Route("getsinglerangeprojection/{symboltype:int,symbol,requestdate}")> _
Public Function GetSingleRangeProjection(ByVal symboltype As Integer,
ByVal symbol As String,
ByVal requestDate As String) As ProjectedRange
...code here
End Function
Upvotes: 0
Views: 1357
Reputation: 5162
the answer is they all get separated by slashes as shown below
<HttpGet()> _
<Route("getsinglerangeprojection/symboltype/{symboltype:int}/symbol/{symbol}/requestdate/{requestDate:datetime}")> _
Public Function GetSingleRangeProjection(ByVal symboltype As Integer,
ByVal symbol As String,
ByVal requestDate As String) As ProjectedRange
...code here
End Function
Upvotes: 2
Reputation: 11591
You should create a model to represent your data like this
public class MyData
{
public string symboltype { get; set; }
public string symbol { get; set; }
public DateTime requestData { get; set; }
}
And change your method to use the model or JObject as the parameter.
Finally, post the whole json object as a string
data:JSON.stringify({ "symboltype": symboltype, "symbol": symb, "requestDate": dDate});
Hope this help.
Upvotes: 0