Updating project parameters using PUT

Answered

I am attempting to update a project's parameters via the REST API (we are on version 2020.1.5).  The GETs are working fine but when I attempt to PUT a new value, the API just responds with the same value that already exists.  The documentation points out I can use ".../parameters/<parameter_name>/value" but it still just responds with the same value that already exists for that parameter.

Is there a JSON/XML body that is required when calling that PUT?  Is that documented somewhere?

UPDATE:

I started using curl for this and it looks have made some progress... Unfortunately it looks like the curl now just clears out the value I send with the request, so in TeamCity it just says <empty> for that parameter.  Example request:

curl --location --request PUT '<host>/app/rest/latest/projects/id:<project>/parameters/<parameter-name>/value' \
--header 'Authorization: Bearer <token>' \
--header 'Accept: text/plain' \
--header 'Cookie: TCSESSIONID=49ABE8D468A3475195EC68A71818EC41' \
--data-raw '"newvalue"'

 

1
3 comments

Hello Tyler!

This method expects a Property-typed entity as a body, e.g. XML one:

<property name="myParam" value="myNewValue"/>

or JSON:

{
name: "myParam",
value: "myNewValue"
}

Unfortunately, there is no example of the call within the documentation so far; a work is underway, though, to provide an auto-documentation on the TeamCity REST API and we hope to make experimental version available shortly. 
I hope this helps; please let me know if the request works for you with the above amendment.

0

Hi Tyler, I was wondering if you found something that worked, please?

0
Hi Angela,

As mentioned by Fedor, the PUT request expects the XML or JSON body with the Property described in it. Please refer to the documentation: https://www.jetbrains.com/help/teamcity/rest/edit-project-settings.html#Manage+Project-Level+Build+Parameters.

Best regards,
Anton
0

Please sign in to leave a comment.