团队城市使用休息 API 设置构建类型参数



我想用 rest api 设置一个构建参数。然后我做了一些研究,找到了这些文件和文章。

  • https://www.jetbrains.com/help/teamcity/rest-api.html#RESTAPI-TypedParametersSpecification
  • https://confluence.jetbrains.com/display/TCD10/REST+API#RESTAPI-TypedParametersSpecification

我做 http 调用,正如他们上面记录的那样。

请求获取参数

GET
Accept */*
http://myTeamCityServer/app/rest/buildTypes/id:myBuildTypeId/parameters/myParameter/value

响应

200
myValue

请求设置参数

PUT
http://myTeamCityServer/app/rest/buildTypes/id:myBuildTypeId/parameters/myParameter/value
--data yourValue

响应

200
myValue

所以什么都没有改变。PUT响应与GET响应相同。它也返回 200 OK。如何设置构建参数? 我哪里做错了?

提前谢谢。

试错学习; 我通过https提出PUT请求。回应是:

403 Forbidden: Responding with 403 status code due to failed CSRF check: no "Origin" header is present and no authentication provided with the request, consider adding "Origin: http://myTeamCityServer" header.

关于这个响应,我把Origin标题放在请求中,请求按预期工作。

此外,添加X-CSRF-Token标头解决了这个问题。

最新更新