Search code examples
powershellteamcity

why does API call not working in teamcity


I created a powershell script to call rest API. In powershell script I am calling post, get and put methods. script works fine in my machine and also works if I run powershell script directly on build agent machine. But if I create a build step in team city and call .ps1 (powershell file) POST and GET methods are working but PUT method is not working. Build is failing with error :

"Invoke-RestMethod : {"code":404,"errors":[{}]}"

I used below syntax to call PUT API

Invoke-RestMethod -Uri $memberEditUrl -Method Put -Body $memberEditBody -ContentType "application/json"

I logged this command using Write-Host and after build run I went to build log and clicked on logged API URL and called in browser and it is working.

It's only team city where this is not working.

What could be the issue?


Solution

  • My problem was resolved by replacing slash ("/") with tilda "~" for parameter value. No change for colon ":" and it worked.