cohesity / cohesity-powershell-module

This repository provides a PowerShell Module for Cohesity DataPlatform. https://cohesity.github.io/cohesity-powershell-module
Apache License 2.0
42 stars 16 forks source link

The given key 'Content-Type' was not present in the dictionary #243

Open jl4509 opened 5 months ago

jl4509 commented 5 months ago

I have a script that uses Set-CohesityViewDirectoryQuota to set directory quotes. It began failing recently on Linux but still worked on Windows. It was showing a "The given key 'Content-Type' was not present in the dictionary." on line 82 of Invoke-RestApi.ps1. I found a similiar issue for PowerShell.core described at https://github.com/orgs/community/discussions/110246. I suspect this is a change in Invoke-WebRequest behavoir for PowerShell core.

I was able to resolve the issue by modifying utility/Invoke-RestApi.ps1 as shown below.

82: If ($PSVersionTable.PSVersion.Major -ge 6) { 82: $PSBoundParameters.headers += @{"Content-Type"="text/json"} # Added to resolve content-type error. 83: $result = Invoke-WebRequest -UseBasicParsing -SkipCertificateCheck @PSBoundParameters -UserAgent $Global:CohesityUserAgentName -SslProtocol Tls12 84: }

KavishreeShanmugam11 commented 5 months ago

Hi @jl4509 , May I know what version of cohesity powershell module you have been installed in your machine and also the version of the powershell environment?

jl4509 commented 5 months ago

OS is RHEL 8.10, Linux 4.18.0-553.el8_10.x86_64 PowerShell version is 7.4.2 Cohesity.PowerShell module is 1.9.8

On Thu, Jun 6, 2024 at 11:37 PM KavishreeShanmugam11 < @.***> wrote:

Hi @jl4509 https://github.com/jl4509 , May I know what version of cohesity powershell module you have been installed in your machine and also the version of the powershell environment?

— Reply to this email directly, view it on GitHub https://github.com/cohesity/cohesity-powershell-module/issues/243#issuecomment-2153789159, or unsubscribe https://github.com/notifications/unsubscribe-auth/ASVTHDZNQRHYN7DPQNNHFFLZGETHLAVCNFSM6AAAAABIRKUBZOVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCNJTG44DSMJVHE . You are receiving this because you were mentioned.Message ID: @.***>