Creating new time entries using REST API returns 404
I am using redmine 1.2.1.stable with mysql and am having an issue using the REST API to create new time entries.
I am using key authentication and the PHP ActiveResource implementation. Loading Projects, Issues and time entries using the API works without any problems. However, when I try to create a new time entry i get a 404 response.
I execute a POST to https://email@example.com/time_entries.xml
with the following data
<?xml version="1.0" encoding="UTF-8"?><time_entrie> <issue_id>8998</issue_id> <spent_on>2011-09-01</spent_on> <hours>0.57333</hours> <activity_id>9</activity_id> <comments>Comment text</comments> </time_entrie>
The server responds with:
HTTP/1.1 404 Not Found Date: Wed, 05 Oct 2011 07:07:35 GMT Server: Mongrel 1.1.5 Status: 404 X-Runtime: 3 Content-Type: application/xml; charset=utf-8 Content-Length: 1 Cache-Control: no-cache Set-Cookie: _redmine_session=BAh7BjoPc2Vzc2lvbl9pZCIlNDUwMmM3MjlkZGM1OGIzZmQzYmNiOWU5MGU1OTE3Y2Y%3D--2f3124386282fbb78a29f4b4ae58020f9ea13c43; path=/; HttpOnly
Calling the URL directly will output
<?xml version="1.0" encoding="UTF-8"?><time_entries type="array" limit="25" total_count="0" offset="0"></time_entries>
And again, fetching a time entry via GET works without problems.
Here you can find the code i used to reproduce the issue (load time entry id 1 works, then creating a new entry fails with 404): time-entry-test.zip
Any help would be greatly appreciated
#1 Updated by Robert Nürnberg over 8 years ago
Note: you must change the URL in the sample file since there is an additional htaccess protection on the site (this however is not the issue, since i am calling the API from an IP that is not presented with the htaccess protection. You will also obviously have to change the API key :)
#4 Updated by Robert Nürnberg over 8 years ago
- Status changed from New to Resolved
Sorry for the direct assign...
ActiveResource (http://www.redmine.org/projects/redmine/wiki/Rest_api_with_php) causes the Problem. It changes time_entry in time_entries to get the plural form - but instead of keeping the original it tries to convert back to the singular by simply cutting the "s" from the plural form. Since the forward conversion worked it did not check/see the error in the other direction.
I edited the wiki page of the php rest api so that others can patch their version as well.
I patched the file - now it works. Sorry for troubling you and thank you very much for the quick response!