TeamCity 用 rest API 设置 buildType 参数
TeamCity set buildType parameter with rest API
我想用 rest 设置构建参数 api.Then 我做了一些研究并找到了这些文档和文章。
- 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 响应 same。也是return200 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
header 放入请求中,请求按预期工作。
另外加上X-CSRF-Token
header就解决了问题。
我想用 rest 设置构建参数 api.Then 我做了一些研究并找到了这些文档和文章。
- 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 响应 same。也是return200 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
header 放入请求中,请求按预期工作。
另外加上X-CSRF-Token
header就解决了问题。