diff --git a/Invoke-ADORestAPI.ps1 b/Invoke-ADORestAPI.ps1 index 81f03f65..36c15068 100644 --- a/Invoke-ADORestAPI.ps1 +++ b/Invoke-ADORestAPI.ps1 @@ -157,33 +157,28 @@ Specifies the method used for the web request. The acceptable values for this pa ) begin { + # From [Irregular](https://github.com/StartAutomating/Irregular): + # ? -VariableFormat Braces $RestVariable = [Regex]::new(@' -# Matches URL segments and query strings containing variables. -# Variables can be enclosed in brackets or curly braces, or preceeded by a $ or : (?> # A variable can be in a URL segment or subdomain (?[/\.]) # Match the ing slash|dot ... (?\?)? # ... an optional ? (to indicate optional) ... (?: - \{(?\w+)\}| # ... A name in {} OR - \[(?\w+)\]| # A name in [] OR - `\$(?\w+) | # A `$ followed by a OR - \:(?\w+) # A : followed by a + \{(?\w+)\} # ... A name in {} OR ) | - (? # If it's optional it can also be + (? # If it's optional it can also be [{\[](?/) # a bracket or brace, followed by a slash ) (?\w+)[}\]] # then a name followed by } or ] + | # OR it can be in a query parameter: - (?[?&]) # Match The ing ? or & ... - (?[\w\-]+) # ... the parameter name ... + (?[\?\&]) # Match The ing ? or & ... + (?[\$\w\-]+) # ... the parameter name ... = # ... an equals ... (?\?)? # ... an optional ? (to indicate optional) ... (?: - \{(?\w+)\}| # ... A name in {} OR - \[(?\w+)\]| # A name in [] OR - \`$(?\w+) | # A $ followed by a OR - \:(?\w+) # A : followed by a + \{(?\w+)\} # ... A name in {} OR ) ) '@, 'IgnoreCase,IgnorePatternWhitespace') @@ -377,7 +372,7 @@ $($MyInvocation.MyCommand.Name) @parameter $streamIn.Dispose() $PSCmdlet.WriteError( [Management.Automation.ErrorRecord]::new( - [Exception]::new($strResponse, $ex.Exception.InnerException + [Exception]::new("$($ex.Exception.InnerException.Response.StatusCode, $ex.Exception.InnerException.Response.StatusDescription)$strResponse ", $ex.Exception.InnerException ), $ex.Exception.HResult, 'NotSpecified', $webRequest) ) return @@ -402,7 +397,7 @@ $($MyInvocation.MyCommand.Name) @parameter if ($AsByte) { $ms = [IO.MemoryStream]::new() $rs.CopyTo($ms) - $ms.ToArray() + ,$ms.ToArray() $ms.Dispose() return } @@ -424,6 +419,9 @@ $($MyInvocation.MyCommand.Name) @parameter $null = $null # We call Invoke-RestMethod with the parameters we've passed in. # It will take care of converting the results from JSON. + if ($response -is [byte[]]) { + return $response + } $apiOutput = $response | @@ -434,7 +432,7 @@ $($MyInvocation.MyCommand.Name) @parameter # A lot of things in the Azure DevOps REST apis come back as a count/value pair if ($in -eq 'null') { return - } + } if ($ExpandProperty) { if ($in.$ExpandProperty) { return $in.$ExpandProperty @@ -456,7 +454,7 @@ $($MyInvocation.MyCommand.Name) @parameter $in = $_ - if ($in -is [string]) { return $in } + if ($in -is [string]) { return $in } if ($null -ne $in.Count -and $in.Count -eq 0) { return } diff --git a/PSDevOps.psd1 b/PSDevOps.psd1 index 4c69a604..0e19afd6 100644 --- a/PSDevOps.psd1 +++ b/PSDevOps.psd1 @@ -1,5 +1,5 @@ @{ - ModuleVersion = '0.5.4' + ModuleVersion = '0.5.4.1' RootModule = 'PSDevOps.psm1' Description = 'PowerShell Tools for DevOps' Guid = 'e6b56c5f-41ac-4ba4-8b88-2c063f683176' @@ -9,6 +9,11 @@ ProjectURI = 'https://github.com/StartAutomating/PSDevOps' LicenseURI = 'https://github.com/StartAutomating/PSDevOps/blob/master/LICENSE' ReleaseNotes = @' +0.5.4.1: +--- +* Fixing Invoke-ADORestApi issues: #111,#114,#115 +* Attaching .BuildID and .DefinitionID properties to Get-ADOBuild where appropriate. + 0.5.4: --- * Formatting Improvments: @@ -96,14 +101,6 @@ ** Get-ADOProject now has -TestRun, -TestPlan, -Release, and -PendingApproval (and better progress bars) ** Get-ADOWorkItemType now has -Field ** Commands for Picklists: Add/Get/Remove/Update-ADOPicklist -0.4.7 ----- -* New Commands: -** Add/Get/Remove-ADOWiki -** Get-ADOPermission -* Bugfixes: -** Honoring Get-ADOBuild -DefinitionName -* Disconnect-ADO is now run prior at the start of Connect-ADO, and on module unload. '@ } Colors = @{