Prerequisites
Steps to reproduce
When running an Invoke-RestMethod (must run with -Verbose & -Debug) query & the server responds with charset=utf8 this returns the following messages
User-Agent: Mozilla/5.0 (Windows NT 10.0; Microsoft Windows 10.0.26200; en-GB) PowerShell/7.7.0
VERBOSE: WebResponse: 200 OK with application/json payload with body size 69.83 KB (71,511 bytes)
VERBOSE: Failed to Write WebResponse Debug Info: System.InvalidOperationException: The character set provided in ContentType is invalid. Cannot read content as string using an invalid character set.
---> System.ArgumentException: 'utf8' is not a supported encoding name. For information on defining a custom encoding, see the documentation for the Encoding.RegisterProvider method. (Parameter 'name')
at System.Text.EncodingTable.InternalGetCodePageFromName(String name)
at System.Text.Encoding.GetEncoding(String name)
at System.Net.Http.HttpContent.ReadBufferAsString(LimitArrayPoolWriteStream stream, HttpContentHeaders headers)
--- End of inner exception stack trace ---
at System.Net.Http.HttpContent.ReadBufferAsString(LimitArrayPoolWriteStream stream, HttpContentHeaders headers)
at System.Net.Http.HttpContent.WaitAndReturnAsync[TState,TResult](Task waitTask, TState state, Func`2 returnFunc)
at Microsoft.PowerShell.Commands.WebRequestPSCmdlet.WriteWebResponseDebugInfo(HttpResponseMessage response) in C:\ps\k-ps-startuptime\src\Microsoft.PowerShell.Commands.Utility\commands\utility\WebCmdlet\Common\WebRequestPSCmdlet.Common.cs:line 1612 at System.Net.Http.HttpContent.ReadBufferAsString(LimitArrayPoolWriteStream stream, HttpContentHeaders headers)
at System.Net.Http.HttpContent.WaitAndReturnAsync[TState,TResult](Task waitTask, TState state, Func`2 returnFunc)
at Microsoft.PowerShell.Commands.WebRequestPSCmdlet.WriteWebResponseDebugInfo(HttpResponseMessage response) in C:\ps\k-ps-startuptime\src\Microsoft.PowerShell.Commands.Utility\commands\utility\WebCmdlet\Common\WebRequestPSCmdlet.Common.cs:line 1612
DEBUG: WebResponse content encoding: utf-8 (Unicode (UTF-8)) CodePage: 65001
Expected behavior
Should return the Debug Message & not the fallback to returning the verbose catch all message.
Actual behavior
Error details
Environment data
Name Value
---- -----
PSVersion 7.7.0-preview.3
PSEdition Core
GitCommitId 7.7.0-preview.3-10-gf9543fa3ff30f21a3cf86eefc1973c69ecbf272b
OS Microsoft Windows 10.0.26200
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.4
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
Visuals

Prerequisites
Steps to reproduce
When running an
Invoke-RestMethod(must run with -Verbose & -Debug) query & the server responds withcharset=utf8this returns the following messagesExpected behavior
Should return the Debug Message & not the fallback to returning the verbose catch all message.Actual behavior
As AboveError details
No Error is returnedEnvironment data
Visuals