Adaptivecards: [UWP] Specifying data property on Action.Submit as a string doesn't work

Created on 13 Oct 2017  路  3Comments  路  Source: microsoft/AdaptiveCards

In UWP, specifying the data property on Action.Submit as a string does not work...

    {
      "type": "Action.Submit",
      "title": "Comment",
      "data": "action=commentPhoto&photoId=92187"
    }

Object works fine though...

{
  "type": "Action.Submit",
  "title": "Dismiss",
  "data": {
      "action": "dismiss",
      "alarmId": 3
  }
}

When we receive the callback and inspect the Data property on AdaptiveSubmitAction, it's null or empty.

We SHOULD be able to do the following as to support both strings and objects being specified there...

if (submitAction.DataJson.ValueType == JsonValueType.String)
{
    arguments = submitAction.DataJson.GetString();
}
else
{
    arguments = submitAction.DataJson.Stringify();
}

Full repro payload

{
  "type": "AdaptiveCard",
  "version": "1.0",

  "body": [

    {
        "type": "TextBlock",
        "text": "Time to wake up!"
    }

  ],

  "actions": [

    {
      "type": "Action.Submit",
      "title": "Snooze",
      "data": "action=snooze&alarmId=3"
    },
    {
      "type": "Action.Submit",
      "title": "Dismiss",
      "data": "action=dismiss&alarmId=3"
    }

  ]
}

This used to work correctly when DataJson was simply a string (it was correctly returning a string in this case and a JSON string when it was an object). Maybe the fix is that the DataJson property needs to be a IJsonValue rather than a JsonObject?

The schema states that this can be either a String or JSON object.

Area-Renderers Bug Platform-UWP Tag-Toasts-V1

All 3 comments

Schema documentations specifies that Action.Submit data is either a String or Json object so it's definitely something that needs fixing.

From Ricardo...

The likely changes that need to be made to make this work should be something like:

  1. Change AdaptiveSubmitAction.DataJson's type from an IJsonObject to an IJsonValue.
  2. When creating the DataJson field, check if the value is a string or an object, and use IJsonValue.Parse().

This fix was pushed in the PR below, I think the bug was not linked then https://github.com/Microsoft/AdaptiveCards/pull/1092

Was this page helpful?
0 / 5 - 0 ratings