Microsoft teams notification is failing

Hi,

In our octopus deployments, we have one step to notify Microsoft teams and it is consistently failing with the following message:

Step 22: Microsoft Teams Notification

The step failed: Activity Microsoft Teams Notification on the Octopus Server failed with error ‘The remote script failed with exit code 1’.

- Octopus Server

   Invoke-RestMethod : The underlying connection was closed: An unexpected error on a send.

At C:\Octopus\Work\20220228222125-261244-296\Script.ps1 char:1

  • Invoke-RestMethod -Method POST -Uri
    $OctopusParameters [‘HookUrl’] -Body
    ($payloa …
~~~~~~~~~~
~~~~
+  CategoryInfo         :  InvalidOperation:
(System.Net.HttpWebRequest:HttpWebRequest) [Invoke-RestMethid], Webexception + FullyQualifiedErrorId: WebCmdletWebResponseException,Microsoft.powershell.commands.InvokeRestMethodCommand

The remote script failed with exit code 1
The action Microsoft Teams Notification on the Octopus Server failed

Can you please advise how to fix this error and can we make this Microsoft Teams Notification step a non-failing step.

Hi @srivasb5!

Thanks for reaching out, and sorry to hear that you’re having issues with your teams integration.

Just so I can make sure I’m giving you the correct information, are you using the Microsoft Teams - Post a message community step template on this step?

We typically see errors like this when there’s a TLS mismatch - I know this step has been updated to us TLS 1.2 for the web request in the most recent update - is it possible that you don’t have the most-recent version of this step template, and it’s failing because it is not using TLS1.2?

You can follow the steps listed in our documentation to update this both centrally, as well as in the projects that use the step template.

Hope this helps, and please let us know if you have any further questions.

Thanks, Justin for your advice.
We were using the custom teams step template. As per your suggestion, I replaced it with Microsoft Teams-Post a message step template. Now I am getting a different error message:
#############################################################
Run step template: Microsoft Teams - Post a message
Ran for 4 seconds
March 8th 2022 21:08:47Fatal
Activity failed with error ‘The remote script failed with exit code 1’.
The remote script failed with exit code 1
Run script on: Demo1Server
Ran for 3 seconds
March 8th 2022 21:08:46Error
Invoke-RestMethod : Invalid URI: The hostname could not be parsed.
March 8th 2022 21:08:47Error
At D:\Octopus\Work\20220309020844-262091-5513\Script.ps1:10 char:1
March 8th 2022 21:08:47Error

  • Invoke-RestMethod -Method POST -Uri $OctopusParameters[‘HookUrl’] -Bo …
    March 8th 2022 21:08:47Error

March 8th 2022 21:08:47Error
+ CategoryInfo : NotSpecified: (:slight_smile: [Invoke-RestMethod], UriFormat
March 8th 2022 21:08:47Error
Exception
March 8th 2022 21:08:47Error
+ FullyQualifiedErrorId : System.UriFormatException,Microsoft.PowerShell.C
March 8th 2022 21:08:47Error
ommands.InvokeRestMethodCommand
March 8th 2022 21:08:47Error

March 8th 2022 21:08:47Info
Exit code: 1
March 8th 2022 21:08:47Fatal
The remote script failed with exit code 1

I verified the host name is correct and not sure how to fix this.
Please let me know.
Thanks,
Sri

Hi @srivasb5,

Thanks for getting back to us!

Are you able to upload the raw task log of the failed task to our Support Files upload repo please?

I’ll post a link here: Support Files Upload.

Is your Octopus server cloud or self-hosted? If it’s self-hosted, can you send over an export of your project’s process JSON as well, please?

The above information should help us point you in the right direction; let me know if you have any questions!

Kind Regards,
Adam

Hi Adam,

Thanks for getting back to me.
Please see my uploads to your support site.
I was only using one task with that step template to see if the step succeeds.
Thanks,

Sri
ServerTasks-262152.log (7.3 KB)

Hi @srivasb5!

I’ve been keeping an eye on this, it doesn’t look like we’ve got a copy of your process JSON at our support upload site yet - can you confirm you uploaded it, and perhaps try again?

Best,

Hi Justin,

Please see the attached JSON file.
Thanks,

Sri
test-proj-process.json (2.3 KB)

That all looks fine, @srivasb5 - I wonder if it’s an issue with how your webhook URL variable (Teams.WebhookUrl) is configured in your project - is it configured with the full URL copied from your Teams configuration page?

The fact that it’s throwing an Invalid URI error would lead me to think that perhaps the webhook URL isn’t complete in some way.

I hope this helps, and please let me know if you have any further questions.

Thank you, Justin. Creating a new inbound webhook for our channel connector helped.

Sri

Glad to hear, @srivasb5! Please let us know if you have any further questions.

This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.