Post comments to tickets from within MS Teams Message Cards

Hello,

Looking for some guidance from anyone with experience using MS Teams connectors, message cards, and freshservice api to post a note to a freshservice ticket. I am running into an issue finding the appropriate way to send authorization in the request headers from within the MS Teams Message card JSON.

Here is an example of the message card looks like and its JSON format

{
    "@type": "MessageCard",
    "@context": "http://schema.org/extensions",
    "themeColor": "d67900",
    "summary": "Service Request",
    "sections": [
        {
            "activityTitle": "{{ticket.id}}",
            "activitySubtitle": "{{ticket.subject}}",
            "activityImage": "https://media.istockphoto.com/vectors/shopping-cart-icon-vector-id639201180?k=6&m=639201180&s=612x612&w=0&h=-bXAjxhS-GnxKai-e2XbaZY2Sum4BxrBBDo_b1isuHQ=",
            "facts": [
                {
                    "name": "Assigned to",
                    "value": "{{ticket.agent.name}}"
                },
                {
                    "name": "Status",
                    "value": "{{ticket.status}}"
                },
                {
                    "name": "Service Request Cost",
                    "value": "{{ticket.service_request_cost}}"
                }
            ],
            "markdown": true
        }
    ],
    "potentialAction": [
        {
            "@type": "OpenUri",
            "name": "Open Ticket",
            "targets": [
                {
                    "os": "default",
                    "uri": "{{ticket.url}}"
                }
            ]
        },
        {
            "@type": "ActionCard",
            "name": "Add Note",
            "inputs": [
                {
                    "@type": "TextInput",
                    "id": "note",
                    "isMultiline": true,
                    "title": "Add note here..."
                }
            ],
            "actions": [
                {
                    "@type": "HttpPOST",
                    "name": "Submit",
                    "target": "https://cedservicedesk-fs-sandbox.freshservice.com/api/v2/tickets/{{ticket.id_numeric}}/notes",
                    "headers": [
                        {
                            "name": "content-type",
                            "value": "application/json"
                        },
                        {    
                            "name": "authorization",
                            "value": "Basic encode(xxxAPIkeywouldgoherexxx)"  
                        }
                    ],
                    "bodyContentType": "application/json",
                    "body": "{{note.value}}"
                }
            ]
        }
    ]
}

I realize this is a rather specific issue and most likely requires more knowledge of MS Teams documentation but I just can’t seem to find an answer from any of their examples. Appreciate any advice given.

Thanks,

Zach

1 Like

I might not know much about MS Teams expects this to be.

But do you think "content-type" should be "Content-Type" ?

1 Like

Hello @Saif,

Thank you for taking a look at this, unfortunately making your suggested changes did not work. I believe it has something to do with authorizing the response. The api endpoint is legit, as I can use this api in postman and add a note to a ticket, but it requires my API key in the header to do so. I am struggling how to add that authorization in the header that is coming from the MessageCard in MS Teams.

Thanks again for taking time to help me identify the issue.

-Zach