Pass decimal as value in Web API 2 URL

bruce
bruce
Member
40 Points
10 Posts

Hi,

I am working with web api 2.0. I am trying to pass decimal value in url as:

[Route("Convert/{TokenID}/{FromCode}/{ToCode}/{Value:decimal}")]
[HttpGet]
public CurrencyList GetConvert(string TokenID, string FromCode, string ToCode, decimal Value)
{
string IPAddress;
if (TokenID == null) { TokenID = ""; }
IPAddress = clsCommon.GetIPAddress();
if (clsCommon.CheckValidUser(TokenID, IPAddress))
{
return CurrencyModel.ConvertCurrency(TokenID, FromCode, ToCode, Value);
}
else
{
return CurrencyModel.ErrorUserID();
}
}

 

I am requesting as:

../CurrencyConverter/Convert/0Imc33etH42tSgoSqhzAVTHos0vPaJDl8iBiUCf7B5nymC8W7T/USD/EUR/245.0456

But unable to pass throws error as:

HTTP Error 404.0 - Not Found
The resource you are looking for has been removed, had its name changed, or is temporarily unavailable.

 

Views: 12995
Total Answered: 2
Total Marked As Answer: 1
Posted On: 06-Oct-2015 23:29

Share:   fb twitter linkedin
Answers
Smith
Smith
None
2568 Points
74 Posts
         

Hi Bruce,

Your code is ok just add one slash (/) in the end of url as:

../CurrencyConverter/Convert/0Imc33etH42tSgoSqhzAVTHos0vPaJDl8iBiUCf7B5nymC8W7T/USD/EUR/245.0456/
Posted On: 07-Oct-2015 05:37
Dude, u rock!
 - Stevan  29-Sep-2018 00:19
andro
andro
Member
118 Points
3 Posts
         

great man! you save my time.

Posted On: 29-Sep-2018 00:13
 Log In to Chat