Updating statuses in Redmine via the API turned out to be harder than I expected. Taking the representation it sends you, and changing the appropriate values gets you strange behaviour:
- The server responds to the PUT request with 200 OK
- The status is not changed.
After a bunch of trial, error, and googling, I hit upon the solution:
Note:I tried posting the following on the Redmine topic about this, but it was rejected as spam, so I’m posting it here in the hopes that it’ll help someone.
I was able to get it to work using XML:
<?xml version='1.0' encoding='utf-8'?> <issue> <status_id>10</status_id> </issue>
Note that I had to also set the Content-Type header to text/xml (despite .xml already being in the url) for the the update to take.
When I send the equivalent JSON (and Content-Type: application/json) I get an HTTP 500.
To me it’s pretty bonkers that for an API claiming to be RESTful:
– you have to include .xml or .json in the url AND set the Content-Type. Content-Type alone should do the trick.
– the representation that you send to PUT an update is different than the one you GET from the server. (ie.
– the server responds 200 OK for requests where it does no work for whatever reason.
But anyways, that’s how I managed to update the status. Hope it helps someone.