sgtoj / PSConnectWise

PowerShell Module that provide several CmdLets to interact with ConnectWise REST API service.
MIT License
45 stars 13 forks source link

Connectwise Manage 2018.4 breaks REST queries using the fields=* parameter #48

Open TheSystech opened 6 years ago

TheSystech commented 6 years ago

I updated our connectwise manage instance to 2018.4 last night, and found that some queries where I was looking for ServiceboardType by name of the type and the same for service board status weren't working correctly using PSConnectwise.

Through debugging and testing with PostMan I found that connectwise is no longer returning all fields when you specify the fields= query parameter. Instead it was only returning the ID field. While I feel this is a bug in Connectwise at this point, it's also true that with their API, leaving the fields parameter out completely is the same as fields=. Given that I modified my local instance of the PSCWAPIClasses.ps1 file in the BuildCWQueryString function, I added another check before it adds the parameter to the vettedqueryparams, where it basically looks for the parameter name fields, and the value to be * and doesn't add it if that is the case.

So that section of code for me now looks like this: if (![String]::IsNullOrEmpty($p.Value)) { if ( $p.Key -eq "fields" -and $p.Value -eq "*" ) { Write-Debug "fields was for all, so leave it out" } else {

                $vettedQueryParams.Add($p.Key, $p.Value);
            }
        }