christaylorcodes / ConnectWiseControlAPI

PowerShell wrapper for ConnectWise Control
MIT License
70 stars 38 forks source link

Get-CWCSession (500) Internal Server Error #26

Closed CitybookServicesLTD closed 7 months ago

CitybookServicesLTD commented 7 months ago

First of all, thank you @christaylorcodes for that amazing PS module!!

I have trouble with Get-CWCSession command, getting (500) Internal Server Error.

Here is the command: Get-CWCSession -Type 'Access' -Limit 2

Other commands are working fine for me. so it's not a permission issue.

Here is the full error:

PS C:\WINDOWS\system32> Get-CWCSession -Type 'Access' -Limit 2
Invoke-CWCWebRequest : An exception has been thrown.
--> The remote server returned an error: (500) Internal Server Error.
An error has been thrown.
--> 
--> {"errorType":"ArgumentException","message":"Web method does not exist","detail":null}
at Invoke-CWCWebRequest, C:\Program Files\WindowsPowerShell\Modules\ConnectWiseControlAPI\0.3.5.0\Private\Invoke-CWCWebRequest.ps1: line 25
at Get-CWCSession, C:\Program Files\WindowsPowerShell\Modules\ConnectWiseControlAPI\0.3.5.0\Public\PageService\Get-CWCSession.ps1: line 30
at <ScriptBlock>, <No file>: line 1
At C:\Program Files\WindowsPowerShell\Modules\ConnectWiseControlAPI\0.3.5.0\Public\PageService\Get-CWCSession.ps1:30 char:14
+     $Data =  Invoke-CWCWebRequest -Arguments $WebRequestArguments
+              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Write-Error], WriteErrorException
    + FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,Invoke-CWCWebRequest
CitybookServicesLTD commented 7 months ago

I followed the documentation from ConnectWise, downloaded all available endpoints from: https://{server-url:port}/OpenAPIDocument.axd, and I see that the endpoint for get session info is different from the endpoint in this module. in this module it is: '/Services/PageService.ashx/GetHostSessionInfo' and it is POST method but in our server it is: /App_Extensions/1b088c99-69bd-43e6-8176-14a3a9af0552/Service.ashx/host-session-info and it is GET method

CitybookServicesLTD commented 7 months ago

My issue was resolved with the following solution