python-rest-api icon indicating copy to clipboard operation
python-rest-api copied to clipboard

Lookup method can raise HTTP 400 with errors body

Open chkwok opened this issue 7 years ago • 1 comments

When looking up a phone number to do preliminary validation, the API can raise a HTTPError instead of ErrorException, as the HTTP status code 400 is not handled in the client.

Raising an ErrorException would be more consistent, as a HTTPError usually indicates networking errors or bad requests, not "phone number seems invalid".

Sample response:

x
Out[91]: requests.exceptions.HTTPError('400 Client Error: Bad Request for url: https://rest.messagebird.com/lookup/1234567890')

x.response.content
Out[92]: b'{"errors":[{"code":21,"description":"Bad request (phone number has unknown format)","parameter":"phone_number"}]}\n'```

chkwok avatar Dec 06 '18 13:12 chkwok

just experienced this one as well. very annoying. and not fixed since 2018!

sehmaschine avatar Aug 31 '20 14:08 sehmaschine