I use the following powershell and REST-API to upload attachment
class TfsHelper{
#...
[string]UploadPng([string]$TfsProject, [string]$PngFileName) {
$uri = "http://$organization/$TfsProject/_apis/wit/attachments?fileName=image.png&api-version=5.1"
$strPngBase64 = [convert]::ToBase64String((Get-Content $PngFileName -Encoding byte))
$rtn = Invoke-RestMethod -Uri $uri -Method POST -Headers $this.Header `
-Body $strPngBase64 `
-ContentType 'application/octet-stream'
return $rtn.url
}
}
The function UploadPng executed successfully and I can also get the response which contains the uploaded PNG url and uuid
But when I opened response url in browser to check the uploaded PNG, I found the uploaded image was not shown as expected and not same as the original one.
So, what`s wrong with the function UploadPng?