twilio: fix false negative failure - sms was sent successfully (#3033)
This commit is contained in:
parent
e226211c5b
commit
91277fc0c7
1 changed files with 6 additions and 2 deletions
|
@ -161,8 +161,12 @@ def main():
|
||||||
for number in to_number:
|
for number in to_number:
|
||||||
r, info = post_twilio_api(module, account_sid, auth_token, msg,
|
r, info = post_twilio_api(module, account_sid, auth_token, msg,
|
||||||
from_number, number, media_url)
|
from_number, number, media_url)
|
||||||
if info['status'] != 200:
|
if info['status'] not in [200, 201]:
|
||||||
module.fail_json(msg="unable to send message to %s" % number)
|
body_message = "unknown error"
|
||||||
|
if 'body' in info:
|
||||||
|
body = json.loads(info['body'])
|
||||||
|
body_message = body['message']
|
||||||
|
module.fail_json(msg="unable to send message to %s: %s" % (number, body_message))
|
||||||
|
|
||||||
module.exit_json(msg=msg, changed=False)
|
module.exit_json(msg=msg, changed=False)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue