textbelt icon indicating copy to clipboard operation
textbelt copied to clipboard

Failure message vague when content type not set, could be improved

Open daluu opened this issue 8 years ago • 1 comments

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_.

daluu avatar Jul 24 '15 06:07 daluu

This totally tripped me. Thanks for sharing it.

robsilva avatar Jul 30 '16 18:07 robsilva