Updating Redmine’s Issue Status via the “REST” API

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. 10 vs. )
– 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.

This entry was posted on Sunday, February 26th, 2012 at 9:22 pm and is filed under General. You can follow any responses to this entry through the RSS 2.0 feed. Both comments and pings are currently closed.

One Response to “Updating Redmine’s Issue Status via the “REST” API”

  1. Heds Says:

    It helps me!

    I’d already found that the syntax had to change when updating the assigned_to field (you have to add it as a value, rather than as the attribute you get back, and it has to be the id of the user, not the name).

    I agree with your comments that it’s not RESTful, I really wish there was some consistency to it, the content-type issue tripped me at first, too.

    Anyway, thanks dude. :)