REST API: archive project / move build configuration to archived project.

Answered

Hello All,

Is there any way to archive a project or move build configuration to archived project using REST API?

 

Thanks,

PF

4 comments
Comment actions Permalink

Yes, you can use the following:

PUT http://<TeamCity Server host>:<port>/app/rest/projects/<projectLocator>/archived

The endpoint accepts text/plain and uses true or false to set the desired status. For more information, please see https://www.jetbrains.com/help/teamcity/rest/manage-projects.html#Project+Settings.

1
Comment actions Permalink

Thanks Eric Borchardt   Could you give me an example of that request in Python, because now I received information (GET method) if the project is archived or not.

 

archiveProject = TC_BASE_URL + "/app/rest/buildTypes/{}".format('ProjectTest')
project = requests.get(changeProject, auth=BearerAuth(TOKEN),

verify=False, headers={"Content-Type": "application/xml"})

print(project.text)

 


I am considering whether or not I should use another method:

GET/DELETE/PUT http://<TeamCity Server host>:<port>/app/rest/projects/<projectLocator>/parameters/<parameter_name>

but I have the same issue.

0
Comment actions Permalink

Here is an example of a GET request to retrieve the archived status of a project using Python

import requests

url = "<teamcity url>/app/rest/projects/<project>/archived"

payload={}

headers = {

  'Authorization': 'Bearer <token>',

}

response = requests.request("GET", url, headers=headers, data=payload)

print(response.text)

 

Here is an example of a PUT request to archive a project using Python

import requests

url = "<teamcity url>/app/rest/projects/<project>/archived"

payload = "true"

headers = {

  'Authorization': 'Bearer <token>',

  'Content-Type': 'text/plain',

}

response = requests.request("PUT", url, headers=headers, data=payload)

print(response.text)
1

Please sign in to leave a comment.