Created
November 19, 2018 06:40
-
-
Save hclpandv/53f73258b719ed4173c620d7bb5cc729 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function Invoke-RestApiCall(){ | |
| #This is function to be used in PS 2.0 version | |
| param( | |
| [string]$Uri , | |
| [string]$Method = "GET" , | |
| [int]$RequestTimeout=60000 , #Milliseconds | |
| [string]$ContentType | |
| ) | |
| [Net.HttpWebRequest] $request = [Net.WebRequest]::create($Uri) | |
| $request.Method = "GET" | |
| $request.Timeout = $RequestTimeout | |
| $request.ContentType = $ContentType | |
| $response = $request.getresponse() | |
| [IO.Stream] $Stream = $response.GetResponseStream() | |
| [IO.StreamReader] $Reader = New-Object IO.StreamReader($Stream) | |
| write-output $Reader.readToEnd() | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment