ConnectWiseManageAPI icon indicating copy to clipboard operation
ConnectWiseManageAPI copied to clipboard

New-CWMTicket always returns an error about insecure redirection

Open CDSFounder opened this issue 1 year ago • 3 comments

I have installed the latest version of ConnectWiseManageAPI module in a Powershell 7.4 environment. I do not have any issues with most of the commands, however the New-CWMTicket command always generates the following error for me:

Line | 40 | … $Result = Invoke-CWMWebRequest -Arguments $WebRequestArguments | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | An error has been thrown. --> --> Cannot follow an insecure redirection by default. Reissue the command specifying the -AllowInsecureRedirect switch. at | Invoke-CWMWebRequest, C:\Users\Chris\<redacted>\Documents\PowerShell\Modules\ConnectWiseManageAPI\0.4.14.0\Private\Invoke\Invoke-CWMWebRequest.ps1: line 45 at Invoke-CWMNewMaster, C:\Users\Chris\<redacted>\Documents\PowerShell\Modules\ConnectWiseManageAPI\0.4.14.0\Private\Invoke\Invoke-CWMNewMaster.ps1: line 40 at New-CWMTicket, | C:\Users\Chris\<redacted>\Documents\PowerShell\Modules\ConnectWiseManageAPI\0.4.14.0\Public\Service\Tickets\New-CWMTicket.ps1: line 328 | at <ScriptBlock>, <No file>: line 1

I have tried: -Closing and re-opening Visual Studio -Disconnect / Reconnect CWM connection -Confirmed that several of the "GET" commands work fine.

This error occurs even when using the minimum required parameters. Example: New-CWMTicket -Summary "test" -company @{id = 19297}

CDSFounder avatar Feb 21 '24 18:02 CDSFounder

I get the same for creating a new company contact.

tld6764 avatar Feb 29 '24 19:02 tld6764

I have found the following:

Parameters -AllowInsecureRedirect Allows redirecting from HTTPS to HTTP. By default, any request that is redirected from HTTPS to HTTP results in an error and the request is aborted to prevent unintentionally communicating in plain text over unencrypted connections. To override this behavior at your own risk, use the AllowInsecureRedirect parameter.

This parameter was added in PowerShell 7.4.

https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.utility/invoke-webrequest?view=powershell-7.4#parameters

tld6764 avatar Feb 29 '24 20:02 tld6764

Invoke-CWMWebRequest.ps1...look around the middle (line 45 for me). Update it from: $Result = Invoke-WebRequest @Arguments -UseBasicParsing To the following: $Result = Invoke-WebRequest @Arguments -UseBasicParsing -AllowInsecureRedirect Then close and reload PowerShell and the CW module. That fixed it for me.

tld6764 avatar Feb 29 '24 20:02 tld6764

There was an issue with ConnectWise's proxy. Please reopen if this is still an issue.

christaylorcodes avatar Sep 03 '24 23:09 christaylorcodes