简体   繁体   中英

float in REST-API call

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?

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)

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM