Updating a time entry: http://www.redmine.org/projects/redmine/wiki/Rest_TimeEntries#Updating-a-time-entry results always in a 404
I'm using Redmine 3.4.6.stable and was using: PUT /time_entries/[id].xml
Other action like: Creating a time entry is working.
Also, Delete is not working and I tried it with JSON as a replacement for XML, but with the same response.
Then I removed the extension like this: /time_entries/[id] and I got a 422, but the response gives me a full HTML page with:
Invalid form authenticity token.I'm not a Ruby/Rails developer, but in routes.rb I can see:
match '/time_entries/:id', :to => 'timelog#destroy', :via => :delete, :id => /\d+/
This is the only entry for: /time_entries/:id
so this means that the documentation at: http://www.redmine.org/projects/redmine/wiki/Rest_TimeEntries#Updating-a-time-entry is outdated and there is no end point for updating a time entry. Is this correct?
I also filed a ticket in Redmine: http://www.redmine.org/issues/31288 but I think I'll get here much faster an answer/help.
This is the Groovy code I'm using for updating an issue:
def baseUrl = new URL("${Config.host}/time_entries/${timeEntry.key}.xml?key=${Config.redmineKey}")
new HTTPBuilder(baseUrl).request(Method.PUT, ContentType.XML) {
body = "<time_entry><id>9956</id><project_id>25</project_id><issue_id>${timeEntry.key}</issue_id><spent_on>${spentOnDate}</spent_on><hours>${new Date(timeEntry.value.toInteger()).format("HH:mm")}</hours><activity_id>9</activity_id><comments></comments></time_entry>"
response.success = { resp, xml ->
println "Success! ${resp.status}"
}
response.failure = { resp ->
println "Request failed with status ${resp.status}"
def outputStream = new ByteArrayOutputStream()
resp.entity.writeTo(outputStream)
def errorMsg = outputStream.toString('utf8')
println errorMsg
}
}