2016-04-26 58 views
0

我試圖在.NET中接收關於TeamCity構建的信息。所有工作都很好,除了一個:我嘗試使用REST API的請求獲取構建名稱。TeamCity REST API錯誤:請求處理期間發生錯誤(不可接受)

這裏是我的要求:

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

,這裏是我的錯誤:請求處理(不接受)過程中發生錯誤。 錯誤:javax.ws.rs.WebApplicationException 不支持的請求。請檢查URL,HTTP方法和傳輸的數據是否正確。

在瀏覽器中,我收到了正確的純文本信息。 REST API有什麼問題?所有其他請求都很好。

回答

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 
相關問題