CodeyThoughts
CodeyThoughts

Reputation: 13

Passing the value of the select list, to the callback url body on office365 connector card? (payload format)

I'm trying to develop a connector.

I have created the card and the webhook and entered a callback URL to my node.js server for httpost action. I can't get the value of the select list to pass to my server when I click send.

I tried including a body string at the card but then I get

SyntaxError: Unexpected token # in JSON at position 0.

When I send without a body it communicates with my server but I cant get the values. I log the request and there are nowhere.

Below is the a section of the code sample of one office365 connector cards for outlook. It is written in the card reference that the httppost action can contain a body. So i assume this body will be sen to my server with the valu ethat i define. But when i include the body i get the above error and the action doesn't complete as it does without a body.

{
        "@type": "ActionCard",
        "name": "Move",
        "inputs": [
            {
                "@type": "MultichoiceInput",
                "id": "move",
                "title": "Pick a list",
                "choices": [
                    { "display": "List 1", "value": 500 },
                    { "display": "List 2", "value": 600 }
                ]
            }
        ],
        "actions": [
            {
              "@type": "HttpPOST",
              "name": "Save",
              "target": "https://aptdevserver.westeurope.cloudapp.azure.com/chat/messages/create",
              "body": "value",
              "bodyContentType": "application/json"
            }
        ]
    }

Upvotes: 0

Views: 114

Answers (1)

Marc LaFleur
Marc LaFleur

Reputation: 33124

You're not telling Outlook which value you want to send. You need to tell it that you want to do a string replacement, otherwise you are litterally sending the string value in the body of your POST:

"body": "{ \"move\": \"{{move.value}}\" }"

Using your complete example:

{
  "@type": "ActionCard",
  "name": "Move",
  "inputs": [
    {
      "@type": "MultichoiceInput",
      "id": "move",
      "title": "Pick a list",
      "choices": [
        { "display": "List 1", "value": 500 },
        { "display": "List 2", "value": 600 }
      ]
    }
  ],
  "actions": [
    {
      "@type": "HttpPOST",
      "name": "Save",
      "target":
        "https://aptdevserver.westeurope.cloudapp.azure.com/chat/messages/create",
      "body": "{ \"move\": \"{{move.value}}\" }",
      "bodyContentType": "application/json"
    }
  ]
}

Upvotes: 1

Related Questions