$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"
给我错误:
[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.
但是我可以使用相同的URL和PostMan中的Headers来更新参数值。 我哪里错了?
答案 0 :(得分:1)
您可以使用C#:
使用FluentTc库设置构建配置参数new RemoteTc()
.Connect(_ => _.ToHost("teamcity.myserver.io")
.AsUser("MYUSERNAME", "MYPASSWORD"))
.SetBuildConfigurationParameters(
_ => _.Id("SandboxPlayGround_WindowsForms1_Build"),
_ => _.Parameter("Version", "2.3.1.0") );
如果需要,您可以使用以下技术之一从Powershell调用此代码: http://executeautomation.com/blog/calling-c-code-in-powershell-and-vice-versa/