Forum Discussion

thadthig's avatar
thadthig
Copper Contributor
Feb 02, 2021

Custom incoming webhook URL not working

Having trouble testing my custom incoming webhook.  Messages POSTed are not being delivered and a strange message is returned in the tools.  I an calling getSettings() inside  registerOnSaveHandler() handler to capture the webhook URL to send to my backend but the URL is not working.  The connector saves and all else looks fine.

 

Response in Postman:

Microsoft.Griffin.Connectors.Common.Exceptions.ExchangeException: Could not load file or assembly 'Microsoft.IdentityModel.Logging, Version=6.5.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.

 

I have used the same tests in the past but today they are not working.  

 

Any help would get appreciated,

Thad

 

Code Snippet:

 

 

        function onClick() {
            microsoftTeams.settings.setValidityState(true);
        }

        microsoftTeams.initialize();
        microsoftTeams.settings.registerOnSaveHandler(function (saveEvent) {
            var radios = document.getElementsByName('notificationType');

            var eventType = '';
            if (radios[0].checked) {
                eventType = radios[0].value;
            } else {
                eventType = radios[1].value;
            }

            microsoftTeams.settings.setSettings({
                entityId: eventType,
                contentUrl: host + "teams/connect",
                removeUrl: host + "teams/connect",
                configName: eventType
            });

            microsoftTeams.settings.getSettings(function (settings) {
                console.log(settings)
                document.getElementById("url").innerText = settings.webhookUrl;

                $.ajax({
                    type: 'POST',
                    url: host + 'teams/connect',
                    data: {'webhook': settings.webhookUrl, 'check': 1, 'notify': 1},
                    success: function (data, status) {
                        saveEvent.notifySuccess();
                    },
                    error: function (error) {
                        $('#debug').text('error: ' + error);
                        saveEvent.notifyFailure('register error');
                    }
                });
            });
        });

        microsoftTeams.settings.registerOnRemoveHandler(function (removeEvent) {
            var removeCalled = true;
            alert("Removed" + JSON.stringify(removeEvent));
        });

 

 

 

 

 

2 Replies

  • Nikitha-MSFT's avatar
    Nikitha-MSFT
    Iron Contributor

    thadthig - the data variable should be stringified in the ajax call. Could you please check the below code?

    microsoftTeams.settings.getSettings(function (settings) {
                // We get the Webhook URL in settings.webhookUrl which needs to be saved.
                $.ajax({
                    url: '/Home/Save',
                    type: 'post',
                    contentType: 'application/json',
                    data: JSON.stringify({
                        webhookUrl: settings.webhookUrl,
                        eventType: eventType
                    }),
                    success: function (data, textStatus, jQxhr) {
                        console.log('webhook created successfully.');
                    },
                    error: function (jqXhr, textStatus, errorThrown) {
                        console.log('error', errorThrown);
                    }
                });
            });
            saveEvent.notifySuccess();
    • thadthig's avatar
      thadthig
      Copper Contributor

      Nikitha-MSFT Thanks for the reply, but I disagree this is the issue.  The post payload is getting sent to my backend just fine.  I also display it on the UI and I just cut and paste it into Postman.  

       

      Like I said it used to work and is working again today without any code changes.  I will test and see if it happens again.

       

      Next hurdle is the new message at the bottom: Possible https://answers.microsoft.com/en-us/msteams/forum/all/microsoft-teams-important-your-connector-is/59452bf4-f87a-4503-9bfb-a8333724bee5.

       

      Regards,

      Thad

       

Resources