Create From Template with REST API
Hi,
how can I create a new build configuration from a template?
I did a POST to
/httpAuth/app/rest/projects/id:project2/buildTypes
with the XML
<newBuildTypeDescription name='Conf Name' sourceBuildTypeLocator='id:(template:btTemplate2)'/>
but the response is:
Error has occurred during request processing (Not Found). Error: jetbrains.buildServer.server.rest.errors.NotFoundException: No build type is found by locator 'id:(template:btTemplate2)' (template is found instead). Could not find the entity requested. Check the reference is correct and the user has permissions to access the entity.
Thanks in advance,
Alexander
Please sign in to leave a comment.
Try PUT template id to /httpAuth/app/rest/projects/id:project2/buildTypes/<locator>/template
Thanks!
Can you give me an example, because the request
/httpAuth/app/rest/projects/id:project2/buildTypes/id:(template:btTemplate2)/template
returns
Error has occurred during request processing (405). Error: javax.ws.rs.WebApplicationException Not supported request. Please check URL, HTTP method and transfered data are correct. metadata: [Allow:[GET,OPTIONS,HEAD],]
Btw: I'm using TeamCity 7.0.3.
Should it be GET/PUT/POST and what should be in the body? Something like this:?
<newBuildTypeDescription name='Conf Name'/>
Thanks in advance,
Alexander
Hi,
Try something like:
curl -v --user USERNAME:PASSWORD --request PUT http://localhost:8111/httpAuth/app/rest/buildTypes/bt52/template -d btTemplate4 --header "Content-Type: text/plain"
Thanks! That worked.