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.
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: ( [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
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,
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?
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.