[ngw] GW2014 REST-API and PowerShell

Morris Blackham mblackham at gw.novell.com
Wed Feb 25 20:25:50 UTC 2015


Let me put together a couple and post em here..

--MB
>>> "James Taylor" <James.Taylor at eastcobbgroup.com> 2/25/2015 10:55 AM
>>>
Hi Morris -
The web based doc for access to the GW2014 functions are great, but I
haven't been able to find any good examples of usage for bash scripts
or
command strings I can use on linux.
Are they out there anywhere?
-jt 


James Taylor
678-697-9420
james.taylor at eastcobbgroup.com



>>> "Morris Blackham" <mblackham at gw.novell.com> 2/25/2015 11:19 AM >>>

Uwe,  took your example,  tweaked variables to match my system,  and
it
worked for me with  PwrShell v4 on Win2012R2.  Not sure what is the
issue with yours.

FYI,  you can modify the command to search for a FID, 
gwadmin-service/list/user?fileId=xxx
That way,  you don't have to know the domain or po for the user.   Or
maybe you knew that already...

--Morris
>>> "Barth Uwe" <Uwe.Barth at stadt-chemnitz.de> 2/25/2015 2:01 AM >>>
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

_______________________________________________
ngw mailing list
ngw at ngwlist.com
http://ngwlist.com/mailman/listinfo/ngw

_______________________________________________
ngw mailing list
ngw at ngwlist.com
http://ngwlist.com/mailman/listinfo/ngw


More information about the ngw mailing list