1
$url = "https://teamcity.myserver.io/guestAuth/app/rest/buildTypes/id:SandboxPlayGround_WindowsForms1_Build/parameters/Version" 

$headers = New-Object "System.Collections.Generic.Dictionary[[String],[String]]"

$headers.Add("Content-Type", 'text/plain')

$headers.Add("Origin", 'https://teamcity.myserver.io')

Invoke-RestMethod -Method Put -Uri $url -Headers $headers -Body "2.3.1.0"

Gives me error:

[19:54:59][Step 2/6] Invoke-RestMethod : HTTP Status 405 - Request method 'PUT' not supported
[19:54:59][Step 2/6]
[19:54:59][Step 2/6]
[19:54:59][Step 2/6]
[19:54:59][Step 2/6] type Status report
[19:54:59][Step 2/6] message Request method 'PUT' not supported
[19:54:59][Step 2/6] description The specified HTTP method is not allowed for the requested resource.

But I can update Parameter value using the same URL and Headers from PostMan just fine. Where am I going wrong?

Boris Modylevsky
  • 3,029
  • 1
  • 26
  • 42
lbrahim
  • 3,710
  • 12
  • 57
  • 95

1 Answers1

1

You can set build configuration parameter using FluentTc library using C#:

new RemoteTc()
  .Connect(_ => _.ToHost("teamcity.myserver.io")
    .AsUser("MYUSERNAME", "MYPASSWORD"))
  .SetBuildConfigurationParameters(
    _ => _.Id("SandboxPlayGround_WindowsForms1_Build"),
    _ => _.Parameter("Version", "2.3.1.0") );

If needed you may call this code from Powershell using one of these techniques: http://executeautomation.com/blog/calling-c-code-in-powershell-and-vice-versa/

Boris Modylevsky
  • 3,029
  • 1
  • 26
  • 42