rveachkc / pymsteams

Format messages and post to Microsoft Teams.
https://pypi.org/project/pymsteams/
Apache License 2.0
428 stars 79 forks source link

Adding Text to Card does not work if PotentialAction or CardSection is added prior #123

Closed securityYam closed 2 years ago

securityYam commented 2 years ago

Describe the bug If a connectorcard object adds a potentialaction or cardsection prior to the text being set, no changes to the text can be set.

To Reproduce Steps to reproduce the behavior:

  1. Create connectorcard object
  2. Create potentialaction / cardsection object and fill in as necessary
  3. Add potentialaction / cardsection to connectorcard
  4. connectorcard.text = 'Some text'
  5. connectorcard.send() yields 'pymsteams.TeamsWebhookException: Summary or Text is required.' connectorcard.payload is missing key for text

Expected behavior text(inputText) should be updating the payload dict with key-value pair of 'text' : inputText

Additional context Strangely enough, the workaround for this is to set the connectorcard's payload manually, i.e. connectorcard.payload['text'] = 'This is some text'. This is bizarre, since this is what the text() method is already doing.

Also tried: payload = connectorCard.payload payload['text'] = 'Testing123' connectorCard.payload = payload which seemed to work. Weird.