VeeamNotify icon indicating copy to clipboard operation
VeeamNotify copied to clipboard

[BUG] 2.1.1 not sending to Teams

Open tedcrawford opened this issue 1 year ago • 6 comments

What happened?

After configuring the latest version I am unable to send notifications to teams. I have tested the webhook an it's still valid

Steps To Reproduce

Follow manual installation steps using v2.1.1 edit conf.json to enable teams as true and insert webhook, user_id, display_name run backup job

VeeamNotify version

v2.1.1

PowerShell version

5.1

Veeam Backup & Replication build number

12.3.1.1139

Relevant log output

conf.json

{
    "services": {
        "discord": {
            "enabled": false,
            "webhook": "DiscordWebhook",
            "user_id": "123456789"
        },
        "slack": {
            "enabled": false,
            "webhook": "SlackWebhook",
            "user_id": "A1B2C3D4E5"
        },
        "teams": {
            "enabled": true,
            "webhook": "https:webhook",
            "user_id": "[email protected]",
            "display_name": "Your Name"
        },
        "telegram": {
            "enabled": false,
            "bot_token": "TelegramBotToken",
            "chat_id": "TelegramChatID",
            "user_name": "yourusername"
        },
        "http": {
            "enabled": false,
            "url": "EndpointURL",
            "method": "POST"
        }
    },
    "mentions": {
        "on_failure": false,
        "on_warning": false,
        "on_success": false
    },
    "notifications": {
        "on_success": true,
        "on_failure": true,
        "on_warning": true
    },
    "logging": {
        "enabled": true,
        "level": "debug",
        "max_age_days": 7
    },
    "update": {
        "notify": true,
        "auto_update": false,
        "auto_update_comment": "auto_update is not yet implemented. This will do nothing even if 'true'."
    },
    "thumbnail": "https://raw.githubusercontent.com/tigattack/VeeamNotify/main/asset/thumb01.png"
}


from log: 

Windows PowerShell transcript start
Start time: 20250805100841
Username: SYD03G1VBK01\veeamadmin
RunAs User: SYD03G1VBK01\veeamadmin
Configuration Name: 
Machine: SYD03G1VBK01 (Microsoft Windows NT 10.0.20348.0)
Host Application: C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -NoProfile -File C:\VeeamScripts\VeeamNotify\AlertSender.ps1 -JobId 0a808045-1aa3-4417-853b-306fd1dc5aab -SessionId f001f60f-b806-4afc-a440-2e604c7e02e8 -JobType Backup -Config {  "services": {    "discord": {      "enabled": false,      "webhook": "DiscordWebhook",      "user_id": "123456789"    },    "slack": {      "enabled": false,      "webhook": "SlackWebhook",      "user_id": "A1B2C3D4E5"    },    "teams": {      "enabled": true,      "webhook": "https://webhookremoved",      "user_id": "[email protected]",      "display_name": "Your Name"    },    "telegram": {      "enabled": false,      "bot_token": "TelegramBotToken",      "chat_id": "TelegramChatID",      "user_name": "yourusername"    },    "http": {      "enabled": false,      "url": "EndpointURL",      "method": "POST"    }  },  "mentions": {    "on_failure": false,    "on_warning": false,    "on_success": false  },  "notifications": {    "on_success": true,    "on_failure": true,    "on_warning": true  },  "logging": {    "enabled": true,    "level": "debug",    "max_age_days": 7  },  "update": {    "notify": true,    "auto_update": false,    "auto_update_comment": "auto_update is not yet implemented. This will do nothing even if 'true'."  },  "thumbnail": "https://raw.githubusercontent.com/tigattack/VeeamNotify/main/asset/thumb01.png"} -Logfile C:\VeeamScripts\VeeamNotify\log\2025-08-05_10.08.31-vgc-syd-oss-dev_(Incremental).log
Process ID: 21816
PSVersion: 5.1.20348.2849
PSEdition: Desktop
PSCompatibleVersions: 1.0, 2.0, 3.0, 4.0, 5.0, 5.1.20348.2849
BuildVersion: 10.0.20348.2849
CLRVersion: 4.0.30319.42000
WSManStackVersion: 3.0
PSRemotingProtocolVersion: 2.3
SerializationVersion: 1.1.0.1
**********************
2025-08-05T00:08:41.458Z [INFO] Transcript is being logged to 'C:\VeeamScripts\VeeamNotify\log\2025-08-05_10.08.31-vgc-syd-oss-dev_(Incremental).log'.
PS>TerminatingError(Invoke-RestMethod): "Unable to connect to the remote server"
2025-08-05T00:09:05.615Z [INFO] No update available.
2025-08-05T00:09:05.630Z [DEBUG] Skipping Discord notification as it is not enabled.
2025-08-05T00:09:05.630Z [DEBUG] Skipping Slack notification as it is not enabled.
2025-08-05T00:09:06.536Z [INFO] Teams notification sent successfully.
2025-08-05T00:09:06.536Z [DEBUG] Teams notification response: Webhook message delivery failed with error: Microsoft Teams endpoint returned HTTP error 400 with ContextId 01=2..
2025-08-05T00:09:06.536Z [DEBUG] Skipping Telegram notification as it is not enabled.
2025-08-05T00:09:06.536Z [DEBUG] Skipping Http notification as it is not enabled.
2025-08-05T00:09:06.552Z [DEBUG] Running log cleanup.
VERBOSE: Performing the operation "Remove expired log files" on target "C:\VeeamScripts\VeeamNotify\log".
2025-08-05T00:09:06.552Z [DEBUG] Searching for log files older than 7 days.
2025-08-05T00:09:06.568Z [DEBUG] Found 0 logs files exceeding retention period.
2025-08-05T00:09:06.568Z [INFO] Stopping transcript logging.
**********************
Windows PowerShell transcript end
End time: 20250805100906
**********************

tedcrawford avatar Aug 05 '25 00:08 tedcrawford

What's the job type?

I'll do my best to solve this, but FYI I'm unable to truly test for Teams as I no longer have access to any Teams instance for testing. The best I can do is reproduce payloads and test them with one of Microsoft's Adaptive Cards Designer tools (1, 2).

If I can't figure it out with that method, it's possible there may need to be some back and forth where I provide debugging methods and potential fixes for you to test yourself. Please let me know if you're comfortable modifying PowerShell files and would be willing to do this should it be necessary.

tigattack avatar Aug 14 '25 08:08 tigattack

I suspect ConvertTo-Json may not be converting the full object due to the specified depth being insufficient. If you're willing and able to, could you please test the change in e87ce6969a3158ff06582e00c0a9e11155a9873b?

tigattack avatar Aug 14 '25 09:08 tigattack

Hi. I updated NotificationSender.psm1 with -Compress "$postParams.Body = $Payload | ConvertTo-Json -Depth 10 -Compress" And then re-ran the job. I got the same error message in the log file.

2025-09-20T22:11:20.127Z [DEBUG] Teams notification response: Webhook message delivery failed with error: Microsoft Teams endpoint returned HTTP error 400 with ContextId 01=2..

Just some extra info, when I was on version 1.0 Teams notification worked.

jamesl1234 avatar Sep 20 '25 22:09 jamesl1234

OK, thanks @jamesl1234. I'll dig deeper into this and let you know when I have something else. Thanks for trying it out, I appreciate the help!

tigattack avatar Sep 26 '25 17:09 tigattack

@tigattack I was in the exact same scenario as @jamesl1234. I performed the bug fix and it worked for me. Ty!

WillowsEmbassy avatar Oct 28 '25 17:10 WillowsEmbassy

That's good to know, thanks @WillowsEmbassy. I'll make a release shortly with that fix included, and hopefully another solution can be found for people still experiencing the issue.


A note to anyone else reading: As I mentioned before, I don't have access to Teams for testing, so it's really quite difficult for me to test possible solutions. Since I'm unsure where the issue lies, it's also difficult to make a guess and ask people to try it as it would likely result in a lot of back and forth and wasted time.

It would be amazing if someone with some spare time, access to Teams, and experience with PowerShell would be willing to help out here!

tigattack avatar Oct 28 '25 17:10 tigattack