0

I am getting some values from my API which i want to impute in adaptive card's drop down.

Right now i have my adaptive card parsed like this

 private Attachment CreateAdaptiveCardAttachment()
        {
            string[] paths = { ".", "Cards", "AddingLeaveDetails.json" };
            string fullPath = Path.Combine(paths);
            var adaptiveCard = File.ReadAllText(fullPath);
            JObject json = JObject.Parse(adaptiveCard);

            JArray body = (JArray)json["body"];



            return new Attachment()
            {
                ContentType = "application/vnd.microsoft.card.adaptive",
                Content = JsonConvert.DeserializeObject(adaptiveCard),
            };
        }
Nikhil Bansal
  • 163
  • 3
  • 16
  • What exactly is your problem? Is it not knowing how to dynamically parse the json and add them to the adaptive card ? Or the Adaptive card is not properly rending ?You should tell us what have you tried so far, add code snippets and what does the json look like, we can't help without having these information – Marc Asmar Dec 05 '19 at 10:50
  • @MarcAsmar is it clear to you now? i am still looking for the solution but yes i am reading templating..still posted here cz i need to implement this in short time – Nikhil Bansal Dec 05 '19 at 11:08
  • Were you able to get this working with my answer? If so, please "accept" and upvote it so others can quickly find the answer and I can clear this from my support tracker. If not, let me know how else I can help! – mdrichardson Dec 10 '19 at 19:33
  • how can i update my card in direct line channel, cz the solution you are suggesting needs the card to update then only previous card will be replaced by a new one...and the UpdateActivityAsync works for Teams only as told by you – Nikhil Bansal Dec 12 '19 at 03:08
  • `UpdateActivity` works for any client that supports it, which is usually one that allows normal users to edit their own messages. Teams is the most common one. What client are you using? My guess is a version of WebChat, in which case you cannot update the card as it isn't supported. – mdrichardson Dec 12 '19 at 16:31
  • i am using web client and yes thats what i am saying i cant update the card with values which i am getting from API.. i have gone through the adaptive card roadmap for an autocomplete search view , its present their but their is no date as to when can we get that – Nikhil Bansal Dec 12 '19 at 16:34

1 Answers1

1

I answer that with quite a bit of detail, here. It's a little old, but still very valid. Messing with json in C# gets pretty ugly. I definitely recommend the first option listed there, building the card with the Adaptive Cards Package.

mdrichardson
  • 7,141
  • 1
  • 7
  • 21