Closed mocalv closed 2 years ago
@mocalv, I just want to clarify that this is a Composer bot and not a "code-first" SDK bot, yes? You list the SDK version which is why I ask. If this is, in fact, a Composer bot, could you supply the version of Composer that you are using?
In the meantime, I will assume this is a Composer issue and will attempt a repro.
Correct, I am talking about a Composer bot. Version 2.1.1
I analysed the traffic with mitmproxy.
My test bot:
POST adaptive card to Webex API:
As one can see, Webex sends a 400 bad request back.
With Postman and the Webex documentation, I was able to find the syntax error.
Not working original body:
{
"attachments":[
{
"$schema":"http://adaptivecards.io/schemas/adaptive-card.json",
"body":[
{
"isSubtle": false,
"text": "default text",
"type": "TextBlock",
"weight": "bolder"
}
],
"type":"AdaptiveCard",
"version":"1.0"
}
],
"markdown": null,
"roomId": "[...]",
"text":"6",
"toPersonEmail": null,
"toPersonId": null
}
Working body:
{
"attachments":[
{
"contentType":"application/vnd.microsoft.card.adaptive",
"content":{
"$schema":"http://adaptivecards.io/schemas/adaptive-card.json",
"body":[
{
"isSubtle":false,
"text":"default text",
"type":"TextBlock",
"weight":"bolder"
}
],
"type":"AdaptiveCard",
"version":"1.0"
}
}
],
"markdown": null,
"roomId": "[...]",
"text":"6",
"toPersonEmail": null,
"toPersonId": null
}
So contentType
and content
are missing.
According to Azure live metrics, the GeneratorResult do at least log the correct syntax.
UPDATE: Even though I liked my idea, I am pretty sure it is wrong because it is working with a "code-first" SDK bot. But I still do not know why it is not working with a composer bot.
UPDATE 2
A debug session for the "code-first" bot shows that the variable attach.Content
simply contains the contentType
and content
again. This is not the case for the composer bot.
Debug "code-first" bot - WebexClientWrapper.cs, line 129
Debug composer bot - WebexClientWrapper.cs, line 129
A simple workaround is to use a dopple structure. The first part is used for e.g. the web chat and the second part is used by Webex.
{
"$schema":"http://adaptivecards.io/schemas/adaptive-card.json",
"body":[
{
"isSubtle":false,
"text":"default text",
"type":"TextBlock",
"weight":"bolder"
}
],
"type":"AdaptiveCard",
"version":"1.0",
"contentType":"application/vnd.microsoft.card.adaptive",
"content":{
"$schema":"http://adaptivecards.io/schemas/adaptive-card.json",
"body":[
{
"isSubtle":false,
"text":"default text",
"type":"TextBlock",
"weight":"bolder"
}
],
"type":"AdaptiveCard",
"version":"1.0"
}
}
Thank you for submitting this issue @mocalv. Closing as resolved by the customer.
@mrivera-ms my provided "solution" is really only a workaroud, since a douple structure is painful to maintain. So please consider reopen it. Maybe it is a Composer issue only, but somewhere this problem should be solved.
Version
SDK 4.12.0
Describe the bug
Using the Webex Adapter for sending messages with a adaptive card causes a 400 Bad Request response by the Webex API.
To Reproduce
Steps to reproduce the behavior:
Expected behavior
Correct body send to Webex API.
Additional context
Tested Webex API with Postman and Adaptive Cards which works fine.