[ngw] GW2014 REST-API and PowerShell

Barth Uwe Uwe.Barth at stadt-chemnitz.de
Wed Feb 25 09:01:00 UTC 2015


Hello,

actually I try to use PowerShell v4 for some GroupWise administration
tasks via REST-API. Unfortunately I'm unable to send a simple
Invoke-RestMethod command like this:

<code>
$uri = "https://grpwise.example.com:9710/gwadmin-service"
$gwuser = "johndoe"
$gwpwd = "johndoespassword"
$gwdom = "gwdom"
$gwpo = "gwpo"
$gwfid = "3qq"
$uri += "/domains/" + $gwdom +"/postoffices/" + $gwpo +
"/users?fileId=" + $gwfid
$encoded =
[System.Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes($gwuser+":"+$gwpwd
))
$headers = @{Authorization = "Basic "+$encoded}
Invoke-RestMethod -Uri $uri -Headers $headers -Method GET -Verbose 
</code>

I always get an error like this:

<error>C:\> C:\gwhelper\gwrest.ps1
https://grpwise.example.com:9710/gwadmin-service/domains/gwdom/postoffices/gwpo/users?fileId=3qq

AUSFÜHRLICH: GET
https://grpwise.example.com:9710/gwadmin-service/domains/gwdom/postoffices/gwpo/users?fileId=3qq
with 0-byte payload
Invoke-RestMethod : The underlying connection was closed: An unexpected
error occurred on a send.
In  C:\gwhelper\gwrest.ps1:23 Zeichen:1
+ Invoke-RestMethod -Uri $uri -Headers $headers -Method GET -Verbose
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation:
(System.Net.HttpWebRequest:HttpWebRequest) [Invoke-RestMethod],
WebException
    + FullyQualifiedErrorId :
WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeRestMethodCommand
</error>

The resulting uri is correct (tested with browser). CA-Certificate is
imported in Windows CertStore. Before the import I got a clear SSL
certificate error message for this.

Does someone here use PowerShell v4 with Invoke-RestMethod
successfully?

Uwe



More information about the ngw mailing list