Closed nrao-nmdp closed 4 years ago
Hi,
thanks for raising this. This seems to be an error in the internal serialization component. I'll have a look at the issue and come back to you.
Hi @nrao-nmdp
the issue is that the choices
parameter in the Choices
class (see docs here) requires a list of Choice
(see the documentation here) objects not just a list of strings.
The following code works.
import json
from pyadaptivecards.card import AdaptiveCard
from pyadaptivecards.inputs import Text, Number, Choices
from pyadaptivecards.components import TextBlock, Choice
from pyadaptivecards.actions import Submit
from webexteamssdk import WebexTeamsAPI
api = WebexTeamsAPI()
greeting = TextBlock("Hey hello there! I am a adaptive card")
first_name = Text('first_name', placeholder="First Name")
age = Number('age', placeholder="Age")
c = Choice("asdf", "asdf")
choice_set = Choices(id = "instance-choice", choices=[c], style="compact")
submit = Submit(title="Send me!")
card = AdaptiveCard(body=[greeting, first_name, age, choice_set], actions=[submit])
attachment = {
"contentType": "application/vnd.microsoft.card.adaptive",
"content": card.to_dict()
}
api.messages.create(toPersonEmail="mneiding@cisco.com", text="Fallback", attachments=[attachment])
The error message clearly needs improvement. I have opened an issue(#4) for this.
ERROR:
Any help will be appreciated, Thanks.