textbelt
textbelt copied to clipboard
Failure message vague when content type not set, could be improved
FYI, when one makes an API call without setting the content type header
Content-Type: application/x-www-form-urlencoded
the response is a failure with message _Invalid phone number._ I found this out twice, once while using a browser extension based REST client to test out API and again while using XmlHttpRequest while building a browser extension for the API.
Not all HTTP request tools/libraries auto-set content type (to form for POST requests) unlike curl. Granted developer should know to set it, but sometimes we forget. The error returned isn't very useful for debugging. Perhaps in future should enhance to return a proper failure message in this case like
_Content type header not set or wrong type used. Please use application/x-www-form-urlencoded_.
This totally tripped me. Thanks for sharing it.