TeamCity REST API错误:请求处理期间发生错误(不可接受)

时间:2016-04-26 09:48:19

标签: teamcity teamcity-9.0

我试图在.NET中收到有关TeamCity构建的信息。一切正常,除了一个:我试图获取构建名称,使用REST API请求。

这是我的要求:

https://myteamcity/httpAuth/app/rest/buildTypes/id:<build_id>/name

这是我的错误:请求处理期间发生错误(不可接受)。 错误:javax.ws.rs.WebApplicationException 不支持的请求。请检查URL,HTTP方法和传输的数据是否正确。

在浏览器中,我收到了正确的纯文本信息。 REST API有什么问题?所有其他要求都运作良好。

1 个答案:

答案 0 :(得分:1)

Accept标头可能会导致问题,请尝试将其更改为Accept: text/plain或将其删除。

例如,当我请求时

curl -H "Accept: application/json" http://teamcity/httpAuth/app/rest/buildTypes/id:buildId/name --user user:pass

我收到了同样的错误,但是在将标题的值更改为text/plain之后返回了该名称

curl -H "Accept: text/plain" http://teamcity/httpAuth/app/rest/buildTypes/id:buildId/name --user user:pass

或从请求中删除标题后

curl http://teamcity/httpAuth/app/rest/buildTypes/id:buildId/name --user user:pass