Unter Linux läßt sich eine Webseite mit curl oder wget sehr einfach abfragen.
In der Powershell können dafür zwei Aufruf für das Testen von REST Services aufgerufen werden:
curl/wget sind als Alias für das cmdlet „Invoke-WebRequest“ hinterlegt.
Beispiel für einen sehr einfachen REST Aufruf mit GET um die Version der API abzufragen:
Invoke-WebRequest -Uri http://127.0.0.1:9090/ords/gpi/api/version/ StatusCode : 200 StatusDescription : OK Content : {"version":"1"} RawContent : HTTP/1.1 200 OK Transfer-Encoding: chunked Content-Type: application/json Date: Sun, 21 Oct 2018 16:31:26 GMT ETag: "Aj/F2I7I9tJv0HnVQVyQNka0ylNOD1DCJwMt77AHjZzC59+Udn0CKuCUb0NwiXOcT3nwWkl0nUj+Pyc... Forms : {} Headers : {[Transfer-Encoding, chunked], [Content-Type, application/json], [Date, Sun, 21 Oct 2018 16:31:26 GMT], [ETag, "Aj/F2I7I9tJv0HnVQVyQNka0ylNOD1DCJwMt77AHjZzC59+Udn0CKuCUb0NwiXOcT3nwWkl0nUj+Pyc4zMU0Ow=="]} Images : {} InputFields : {} Links : {} ParsedHtml : mshtml.HTMLDocumentClass RawContentLength : 15
In der Powershell steht einem dafür „Invoke-RestMethod“ bzw als alias „irm“ zur Verfügung.
Beispiel für einen sehr einfachen REST Aufruf mit GET um die Version der API abzufragen:
Invoke-RestMethod -Uri http:\\localhost:9090 version ------- 1
Beim Abfragen eines Webservice, zum Beispiel vom ORDS ⇒ Oracle ORDS 3.0 REST API nativ verwenden ist die Verwendung dieses Befehls sehr praktisch, ein Json Record wird gleich als Tabelle dargestellt.
irm -Uri http://127.0.0.1:9090/ords/gpi/api/version/ version ------- 1
help irm NAME Invoke-RestMethod SYNTAX Invoke-RestMethod [-Uri] <uri> [-Method {Default | Get | Head | Post | Put | Delete | Trace | Options | Merge | Patch}] [-UseBasicParsing] [-WebSession <WebRequestSession>] [-SessionVariable <string>] [-Credential <pscredential>] [-UseDefaultCredentials] [-CertificateThumbprint <string>] [-Certificate <X509Certificate>] [-UserAgent <string>] [-DisableKeepAlive] [-TimeoutSec <int>] [-Headers <IDictionary>] [-MaximumRedirection <int>] [-Proxy <uri>] [-ProxyCredential <pscredential>] [-ProxyUseDefaultCredentials] [-Body <Object>] [-ContentType <string>] [-TransferEncoding {chunked | compress | deflate | gzip | identity}] [-InFile <string>] [-OutFile <string>] [-PassThru] [<CommonParameters>] ALIASES irm REMARKS Get-Help cannot find the Help files for this cmdlet on this computer. It is displaying only partial help. -- To download and install Help files for the module that includes this cmdlet, use Update-Help. -- To view the Help topic for this cmdlet online, type: "Get-Help Invoke-RestMethod -Online" or go to https://go.microsoft.com/fwlink/?LinkID=217034.
help curl NAME Invoke-WebRequest SYNTAX Invoke-WebRequest [-Uri] <uri> [-UseBasicParsing] [-WebSession <WebRequestSession>] [-SessionVariable <string>] [-Credential <pscredential>] [-UseDefaultCredentials] [-CertificateThumbprint <string>] [-Certificate <X509Certificate>] [-UserAgent <string>] [-DisableKeepAlive] [-TimeoutSec <int>] [-Headers <IDictionary>] [-MaximumRedirection <int>] [-Method {Default | Get | Head | Post | Put | Delete | Trace | Options | Merge | Patch}] [-Proxy <uri>] [-ProxyCredential <pscredential>] [-ProxyUseDefaultCredentials] [-Body <Object>] [-ContentType <string>] [-TransferEncoding {chunked | compress | deflate | gzip | identity}] [-InFile <string>] [-OutFile <string>] [-PassThru] [<CommonParameters>] ALIASES iwr wget curl REMARKS Get-Help cannot find the Help files for this cmdlet on this computer. It is displaying only partial help. -- To download and install Help files for the module that includes this cmdlet, use Update-Help. -- To view the Help topic for this cmdlet online, type: "Get-Help Invoke-WebRequest -Online" or go to https://go.microsoft.com/fwlink/?LinkID=217035.