Skip to content

[BUG] Action.Http body with Input.Number trimmed #9386

Description

@fowl2

Action.Http cuts off the first and last digit of the value of a Input.Number substitution.

It does this because StringWithSubstitutions::substituteInputValues() calls JSON.stringify(), then removes the first and last character:

valueForReplace = JSON.stringify(valueForReplace);
valueForReplace = valueForReplace.slice(1, -1);

Presumably it was written assuming the .value will always be a string and therefore be wrapped in double quotes, but in this case, it's a number, and the JSON numbers are unquoted.

For example, entering the number 12.34 will result in a JSON payload of "2.3".

Action.Http Snippet

"body": "{\"numberProperty\":\"{{aNumberInput.value}}\"}",

HTTP POST Body

{"numberProperty":"2.3"}"
Card JSON
{
  "type": "AdaptiveCard",
  "body": [
    {
      "type": "Input.Number",
      "id": "aNumberInput"
    },
    {
      "type": "ActionSet",
      "actions": [
        {
          "type": "Action.Http",
          "title": "Submit",
          "method": "POST",
          "url": "https://example.com",
          "body": "{\"numberProperty\":\"{{aNumberInput.value}}\"}",
          "headers": [
            {
              "name": "Authorization",
              "value": ""
            },
            {
              "name": "Content-Type",
              "value": "application/json"
            }
          ]
        }
      ]
    }
  ],
  "$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
  "version": "1.0"
}

previously reported #5218

Version Tested: adaptivecards@.0.6

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions