MethodsAndPractices / vsteam

PowerShell module for accessing Azure DevOps Services and Azure DevOps Server (formerly VSTS or TFS)
https://methodsandpractices.github.io/vsteam-docs/
MIT License
442 stars 155 forks source link

Invoke-VSTeamRequest call to API returning content application/octet-stream fails #564

Open mnieto opened 4 months ago

mnieto commented 4 months ago

Steps to reproduce

$build = Get-VSTeamBuild -Definitions $pipelineId  -ResultFilter succeeded -Top 1
$artifacts = Get-VSTeamBuildArtifact -id $build.id
Invoke-VSTeamRequest -NoProject -area resources  -resource Containers -id "$($artifacts.id)/drop" -QueryString  @{ itemPath = "drop/myartifactfile.json" }

Expected behavior

As the artifact is a json file, I expect Invoke-VSTeamRequest manages the result and return a psobject representation of the json

As a workarround it's possible to provide the -OutFile parameter to save the content in a temp file and then do

Invoke-VSTeamRequest -NoProject -area resources  -resource Containers -id "$($artifacts.id)/drop" -QueryString  @{ itemPath = "drop/myartifactfile.json" } -OutFile temp.json
Get-Content temp.json | CovertFrom-Json

But this forces to save a file and remove it in an additional step

Actual behavior?

Exception: C:.....\PowerShell\Modules\VSTeam\7.13.0\vsteam.functions.ps1:279 Line | 279 | Write-Verbose $resp | ~ | Cannot convert ' | ' to the type 'System.String' required by parameter 'Message'. Specified method is not supported.

On Which OS have you tried it?

Windows

What was your server version?

Azure DevOps Services

Other server version

No response

Log output of used API

Billing                     : 5.1-preview.1
Build                       : 5.1
Core                        : 5.1
DistributedTask             : 6.0-preview
DistributedTaskReleased     : 5.1
ExtensionsManagement        : 6.0-preview
Git                         : 5.1
Graph                       : 6.0-preview
HierarchyQuery              : 5.1-preview
MemberEntitlementManagement : 6.0-preview
Packaging                   : 6.0-preview
Pipelines                   : 5.1-preview
Policy                      : 5.1
Processes                   : 6.0-preview
Release                     : 5.1
ServiceEndpoints            : 5.0-preview
TaskGroups                  : 6.0-preview
Tfvc                        : 5.1
VariableGroups              : 5.1-preview.1
Version                     : AzD
Wiki                        : 6.0
WorkItemTracking            : 6.0-preview.1

Log output of $PSVersionTable

Name                           Value
----                           -----
PSVersion                      7.3.2
PSEdition                      Core
GitCommitId                    7.3.2
OS                             Microsoft Windows 10.0.19045
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0