messagebird / python-rest-api

This repository contains the open source Python client for MessageBird's REST API.
BSD 2-Clause "Simplified" License
65 stars 66 forks source link

Lookup method can raise HTTP 400 with errors body #27

Open chkwok opened 5 years ago

chkwok commented 5 years ago

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'```
sehmaschine commented 4 years ago

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