devopshq / teamcity

dohq-teamcity is a Python package providing access to the JetBrains TeamCity server API.
https://devopshq.github.io/teamcity/
MIT License
33 stars 12 forks source link

Method is not working due to headers #13

Open smartfin opened 5 years ago

smartfin commented 5 years ago

As we can find in TeamCity documentation there is specific method to get/update some project paramteres:

Project name/description/archived status: GET/PUT http://teamcity:8111/app/rest/projects// (accepts/produces text/plain) where is one of "name", "description", "archived".

It accepts only text/plain headers that's why it's not really easy to use this method with current version of client.

def set_description(tc, locator, description):
    old_default_headers = tc.default_headers.copy()
    tc.set_default_header(header_name='Content-type', header_value='text/plain')
    tc.set_default_header(header_name='Accept', header_value='text/plain')

    result = tc.projects.set_project_filed(project_locator=locator, field='description',
                                           body=description)

    tc.default_headers = old_default_headers.copy()
    del (old_default_headers)

Probably, this method should be updated and this kind of issues with specific headers also handled by client.