1

how can one send float values to a RESTful API?

/api/set/integername/49

/api/set/charname/B

/api/set/floatname/49.33

The third one doesn't work.

404: Not Found

Can float values be encoded somehow to make this possible or do I have to wrap it in a json object?

martinenzinger
  • 2,016
  • 2
  • 16
  • 20

2 Answers2

0

I would just do something simple like convert the decimal point to an underscore :) It's less messy than URL encoding.

Do you have to support scientific notation (ex 1.5e+20)? In that case you'll have to deal with + and -. (though - doesn't need encoding)

seand
  • 5,132
  • 1
  • 23
  • 37
0

This is a duplicate question to Passing double/float through URL to Web Api query string

The answer provided there was to add a slash to the end of the querystring. I've just tested that with a blank Microsoft WebApi2 project and it works a treat.

Community
  • 1
  • 1
snowcode
  • 913
  • 8
  • 22