我試圖使用Groovy腳本和REST API搜索神器:Artifactory的通過REST API搜索導致 「錯誤的請求」 錯誤
def query = ‘artifactory/api/search/artifact?name=at.mic.all.feature&repos=features-qa-test-snapshot’
def server = new RESTClient(‘http://mic-build2.mic.co.at:8081’)
server.parser.'application/vnd.org.jfrog.artifactory.search.ArtifactSearchResult+json' = server.parser.'application/json'
def resp = server.get(path: query)
這會導致異常:
groovyx.net.http.HttpResponseException: Bad Request
at groovyx.net.http.RESTClient.defaultFailureHandler(RESTClient.java:240)
at groovyx.net.http.HTTPBuilder.doRequest(HTTPBuilder.java:508)
at groovyx.net.http.RESTClient.get(RESTClient.java:118)
at groovyx.net.http.RESTClient$get.call(Unknown Source)
at Artifactory.getArtifacts(artifactory.groovy:157)
…
只有要查看服務器和查詢是否正確,我在瀏覽器中嘗試了url = server +'/'+查詢(= http://mic-build2.mic.co.at:8081/artifactory/api/search/artifact?name=at.mic.all.feature&repos=features-qa-test-snapshot),這會導致包含我的搜索結果的文件:
{「results 「:[{」uri「:」http://mic-build2.mic.co.at:8081/artifactory/api/storage/features-qa-test-snapshot/at/mic/all/feature/at.mic.all.feature/20130313002236/at.mic.all.feature-20130313002236-win32.win32.x86.zip「},... ..}}
所以,我的服務器和查詢似乎沒問題,但在我的groovy腳本中不起作用。
在此先感謝您的幫助,親切的問候! Frank