Can't get list of build artifacts using RestAPI
Completed
Hi. Using teamcity documentation for REST API i built url:
http://teamcity-ip:port/app/rest/builds/?locator=buildType:(name:Test%20Configuration),defaultFilter:false,number:623
I decided to use token authentication, i took my token from settings and buit next request with curl:
curl --header "Authorization: Bearer eyJ0eXAiOiAiVENWMiJ9.UjdlM1dUVEtLd1JFWkJncXFoNkZtdHNHNF93.NGYxMjI4MTYtMDg3Yi00O2Q0LTgxNjgtOTr0MjhlU2T4Y2Vi" http://teamcity-ip:port/app/rest/builds/?locator=buildType:(name:Test%20Configuration),defaultFilter:false,number:623
As response for that request i get:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?><builds count="1" href="/app/rest/builds/?locator=buildType:(name:Test%20Configuration),defaultFilter:false,number:623"><build id="1819" buildTypeId="Test_TestProduct" number="623" status="SUCCESS" state="finished" href="/app/rest/builds/id:1819" webUrl="http://teamcity-ip:port/viewLog.html?buildId=1819&buildTypeId=Test_TestProduct"/></builds>
But i want to get artifacts list of that build (there are 3 .zip archives) and download then one or more of them
I try to use requests as in documentations like:
curl --header "Authorization: Bearer eyJ0eXAiOiAiVENWMiJ9.UjdlM1dUVEtLd1JFWkJncXFoNkZtdHNHNF93.NGYxMjI4MTYtMDg3Yi00O2Q0LTgxNjgtOTr0MjhlU2T4Y2Vi" http://teamcity-ip:port/app/rest/builds/?locator=buildType:(name:Test%20Configuration),defaultFilter:false,number:623/artifacts/
or
curl --header "Authorization: Bearer eyJ0eXAiOiAiVENWMiJ9.UjdlM1dUVEtLd1JFWkJncXFoNkZtdHNHNF93.NGYxMjI4MTYtMDg3Yi00O2Q0LTgxNjgtOTr0MjhlU2T4Y2Vi" http://teamcity-ip:port/app/rest/builds/?locator=buildType:(name:Test%20Configuration),defaultFilter:false,number:623/artifacts/content/
or
curl --header "Authorization: Bearer eyJ0eXAiOiAiVENWMiJ9.UjdlM1dUVEtLd1JFWkJncXFoNkZtdHNHNF93.NGYxMjI4MTYtMDg3Yi00O2Q0LTgxNjgtOTr0MjhlU2T4Y2Vi" http://teamcity-ip:port/app/rest/builds/?locator=buildType:(name:Test%20Configuration),defaultFilter:false,number:623/artifacts/files/
but for all requests i get:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?><builds count="0" href="/app/rest/builds/?locator=buildType:(name:Test%20TestConfiguration),defaultFilter:false,number:623/artifacts/"/>
or
<?xml version="1.0" encoding="UTF-8" standalone="yes"?><builds count="0" href="/app/rest/builds/?locator=buildType:(name:Test%20TestConfiguration),defaultFilter:false,number:623/artifacts/content/"/>
or
<?xml version="1.0" encoding="UTF-8" standalone="yes"?><builds count="0" href="/app/rest/builds/?locator=buildType:(name:Test%20TestConfiguration),defaultFilter:false,number:623/artifacts/files/"/>
What i did wrong? How to get list of artifacts and then choose one or more and download them?
Please sign in to leave a comment.
Hello!
I suggest to use this endpoint:
(Of course, you can use any build locator in the endpoint, not just the above.)
Basically, you do not have to specify ?locator= before locator part unless you run request like below (with no slash between builds and actual locator):
Or if you also need to provide custom fields parameter (https://www.jetbrains.com/help/teamcity/rest-api.html#RESTAPI-URLStructure).
The above endpoint will yield a list of files along with the links to the download; please see an example below:
<files count="1">
</files>
Thanks! Other links work fine. I tried with buildId and configurationId