Skip to content

Commit

Permalink
Dont check if the response text is simply '1' because it's sending a …
Browse files Browse the repository at this point in the history
…complex JSON payload
  • Loading branch information
alexadams-ms committed Oct 3, 2022
1 parent d756310 commit 3d455d1
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion pymsteams/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ def send(self):
)
self.last_http_response = r

if r.status_code == requests.codes.ok and r.text == '1': # pylint: disable=no-member
if r.status_code == requests.codes.ok: # pylint: disable=no-member
return True
else:
raise TeamsWebhookException(r.text)
Expand Down

1 comment on commit 3d455d1

@mockodin
Copy link

@mockodin mockodin commented on 3d455d1 Oct 20, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ack'd they changed it however a more complete validation would now be:

try:
    status = json.loads(r.text)
    if r.status_code == requests.codes.ok and status['isSuccessStatusCode'] is True:
        return True
except Exception:
    raise TeamsWebhookException(r.text)

The update of the response body seems to have been done in 2019 but only for new webhooks, I recently saw old webhook begin failing for "r.text == '1'" no longer being valid.

Please sign in to comment.