Open MichaMican opened 9 months ago
Have you tried directly sending card via turnContext.SendActivityAsync()
?
TeamsFx SDK passed your input object to BotBuilder SDK without any serialize/deserialize. See (https://github.com/OfficeDev/TeamsFx/blob/main/packages/dotnet-sdk/src/TeamsFx/Conversation/TeamsBotInstallation.cs#L107-L117)
Also noticed that BotBuilder SDK is based on Newtonsoft.Json (https://github.com/microsoft/botbuilder-dotnet/blob/main/libraries/Microsoft.Bot.Schema/Attachment.cs)
Yes - Same issue unfortunately.
Indeed the SDK is based on Newtonsoft.Json and I think that is exactly the problem here.
So one option is to make input object recognized by Newtonsoft.Json - your workaround already did that.
And another option may be to let ASP.NET Core to use Newtonsoft.Json (https://learn.microsoft.com/en-us/aspnet/core/web-api/advanced/formatting?view=aspnetcore-8.0#add-newtonsoftjson-based-json-format-support-2). But that's a global setting and may impact other APIs in your app.
Describe the bug When calling the
SendAdaptiveCard()
function of aTeamsBotInstallation
with a generic object of typeobject
the internal serialization does not wokr properly and a empty adaptive card is send (see Screenshots)To Reproduce Steps to reproduce the behavior:
Replace the notification PostAsync controller code with the following:
Expected behavior The adaptivecard that was send to the endpoint should be send properly
Screenshots If applicable, add screenshots to help explain your problem.
~VS Code Extension Information (please complete the following information):~ ~- OS: [e.g. iOS]~ ~ - Version [e.g. 22]~
~CLI Information (please complete the following information):~ ~ - OS: [e.g. iOS8.1]~ ~ - Version [e.g. 22]~
TeamsFx Info:
Additional context I worked arround the issue in a very weird way. I basically converted the object to something that Newtonsoft.Json can deserialize properly
then i Deserialize the serializedAdaptiveCard with Newtonsoft JSON
This is an unbelievably dirty workarround. I am not sure if Newtonsoft.Json can be configured to serialize object properly but swapping to System.Text.Json should fix te issue
This issue was initialy opened incorrectly in the botframework-sdk repo. There i was guided towarts this repo