Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Microsoft Teams endpoint returned HTTP error 500 not caught #34

Open
nsleigh opened this issue Apr 15, 2021 · 7 comments
Open

Microsoft Teams endpoint returned HTTP error 500 not caught #34

nsleigh opened this issue Apr 15, 2021 · 7 comments
Labels
enhancement New feature or request

Comments

@nsleigh
Copy link

nsleigh commented Apr 15, 2021

First thanks for publishing this module, it has made Teams integration much easier.

I have found an issue with the code that would be useful to handle. If you send a message to Teams and the body is too large (>17000 characters) then you get this message:

WARNING: Send-TeamsMessage - Couldn't send message. Execute message: Webhook message delivery failed with error: Microsoft Teams endpoint returned HTTP error 500 with ContextId tcid=0,server=msgapi-production-neu-azsc4-2-88,aa=Oxdgc+LR2kAAqmLcffH/jg.0,MS-CV=Oadgc+LA1kAVqmLcffH/jg.0..

But it doesn't set any error variable that can be tested. I think this is because Invoke-RestMethod doesn't throw an error for HTTP status 500. Not sure how best to handle this but may be the code should "throw" on this status.

@PrzemyslawKlys
Copy link
Member

If you will use Send-TeamsMessage -ErrorAction Stop it should stop. Basically, all errors are swallowed as Warnings by default, but you can decide to stop on all errors and handle them yourself. Try it out - maybe it works... if not I can check things out.

@nsleigh
Copy link
Author

nsleigh commented Apr 15, 2021

When I call the function I set "-ErrorVariable teamsError -ErrorAction SilentlyContinue" this allows me to review testsError for non-500 issues. If I set "-ErrorAction Stop" it prints a message but doesn't return anything that can be tested.

Guess this is a change of design in some respects, I am using the code for a long running process and want to be able to review a log if there are issues.

@PrzemyslawKlys
Copy link
Member

why not do WarningVariable/WarningAction then?

@nsleigh
Copy link
Author

nsleigh commented Apr 15, 2021

Every day's a school day - I had complete missed those parameters from any PowerShell I have done. That works perfectly, thanks.

@PrzemyslawKlys PrzemyslawKlys added the enhancement New feature or request label Apr 16, 2021
@tomabg
Copy link

tomabg commented Apr 20, 2021

Hi,

i also had some struggle with this limit but could avoid it finaly by another structure of the data.

Is there an easy to use possibility to count the characters of the message(i use Verbose and copy it to notepad++ and remove all spaces and then count it)

BR
Thomas

@PrzemyslawKlys
Copy link
Member

@tomabg
Copy link

tomabg commented Apr 21, 2021

yeah done this already ..however some hint or INFO would be cool...probably yes add the number of characters to VERBOSE

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants