更新时间条目: http ://www.redmine.org/projects/redmine/wiki/Rest_TimeEntries#Updating-a-time-entry 结果始终为 404
我正在使用 Redmine 3.4.6.stable 并且正在使用:PUT /time_entries/[id].xml
其他操作,例如:创建时间条目正在工作。
此外,Delete 不起作用,我尝试使用 JSON 作为 XML 的替代品,但响应相同。
然后我删除了这样的扩展:/time_entries/[id],我得到了 422,但响应给了我一个完整的 HTML 页面:
无效的表单真实性令牌。我不是 Ruby/Rails 开发人员,但在 routes.rb 中我可以看到:
match '/time_entries/:id', :to => 'timelog#destroy', :via => :delete, :id => /\d+/
这是唯一的条目:/time_entries/:id
因此这意味着位于 http://www.redmine.org/projects/redmine/wiki/Rest_TimeEntries#Updating-a-time-entry的文档 已过时,并且没有更新时间条目的终点。这个对吗?
我还在 Redmine 提交了一张票: http ://www.redmine.org/issues/31288 但我想我会更快地得到答案/帮助。
这是我用来更新问题的 Groovy 代码:
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
}
}