Vote #81124
未完了Time Entries POST doesn't work in JSON format
0%
説明
h1. Environment
fairly stock Redmine 4.1.1, in a docker environment.
Redmine version 4.1.1.stable Ruby version 2.6.6-p146 (2020-03-31) [x86_64-linux-musl] Rails version 5.2.4.2 Environment production Database adapter SQLite Mailer queue ActiveJob::QueueAdapters::AsyncAdapter Mailer delivery smtp SCM: Subversion 1.12.2 Mercurial 5.3.2 Bazaar 2.7.0 Git 2.24.3 Filesystem Redmine plugins: no plugin installed
h1. Steps to reproduce
create a first redmine project¶
create a simple issue¶
allow API access¶
try to POST to /time_entries.xml with Content-Type application/xml¶
1 1 1 2.0 Additional implementation 2020-10-28
try to POST the same data in JSON to /time_entries.json with Content-Type application/json¶
{ "project_id":"1", "issue_id":"1", "user_id":"1", "hours":"2.0", "comments":"Additional implementation", "spent_on":"2020-10-28" }
try to POST the same data but with hours formatted as number to /time_entries.json with Content-Type application/json¶
{ "project_id":"1", "issue_id":"1", "user_id":"1", "hours":2.0, "comments":"Additional implementation", "spent_on":"2020-10-28" }
h1. What happens
in step 4, XML format, the time entry is created, returns with http 201
in step 5 and 6, JSON format, the endpoint returns with 422 Unprocessable Entity, complaining about
{ "errors": [ "Hours cannot be blank" ] }
h1. Expected result
either step 5 or step 6 (or maybe both) should work, to be able to create a time entry using JSON-based REST API
journals
Same problem here
Note that the wiki says that project_id or issue_id is required, not both (i'm not sure it's correct)
https://www.redmine.org/projects/redmine/wiki/Rest_TimeEntries#Creating-a-time-entry
--------------------------------------------------------------------------------
florent thiery wrote:
> Same problem here
>
> Note that the wiki says that project_id or issue_id is required, not both (i'm not sure it's correct)
>
> https://www.redmine.org/projects/redmine/wiki/Rest_TimeEntries#Creating-a-time-entry
That seems perfectly correct, as an issue exists in the context of a project, if you have an issueId, you can find the project easily. And you can log time on project without specifying an issueId, so yes, either one or the other is required. However, it works fine if you specify both values.
--------------------------------------------------------------------------------
Thanks for the precision, i was not aware that you could fill time on a project. I think the wiki should be updated to reflect the possibility of passing user_id
EDIT: i just did it actually
--------------------------------------------------------------------------------