我正在尝试通过 powershell 运行 citrix api,但它给了我错误
底层连接已关闭:发送时发生意外错误。
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 -bor [Net.SecurityProtocolType]::Tls11 -bor [Net.SecurityProtocolType]::Tls
$Citrixheaders = @{'Citrix-CustomerId'=$customerId;'Authorization'=$GLOBAL:XDAuthToken}
$url = "https://api-us.cloud.com/monitorodata/Applications"
(Invoke-RestMethod $url -Headers $Citrixheaders -UseBasicParsing -Method GET -ContentType "application/json" -Verbose -ErrorAction Stop).value
这是我正在运行的代码。
与从 Postman 返回值的标头相同的 api
我检查了互联网并尝试了以下代码,但它也无法正常工作。
#1
$code =@"
public class SSLHandler
{
public static System.Net.Security.RemoteCertificateValidationCallback GetSSLHandler()
{
return new System.Net.Security.RemoteCertificateValidationCallback((sender, certificate, chain, policyErrors) => {return true; });
}
}
"@
Add-type -TypeDefinition $code
[Net.ServicePointManager]::ServerCertificateValidationCallback = [SSLHandler]::GetSSLHandler()
[Net.Servicepointmanager]::Expect100Continue = $true
#2
[Net.Servicepointmanager]::ServerCertificateValidationCallback = $true
[Net.Servicepointmanager]::Expect100Continue = $true
我不知道下一步该怎么做,请给出您的建议