Project

General

Profile

Actions

Defect #8951

closed

404 w/ POST /issues.json (Filter chain halted as [:find_project] rendered_or_redirect)

Added by Ryan Olds over 12 years ago. Updated about 2 months ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Category:
REST API
Target version:
-
Start date:
2011-07-31
Due date:
% Done:

0%

Estimated time:
Resolution:
Cant reproduce
Affected version:

Description

Processing IssuesController#create to json (for 70.89.177.157 at 2011-07-31 17:26:52) [POST]
Parameters: {"format"=>"json", "action"=>"create", "controller"=>"issues", "key"=>"..."}
Filter chain halted as [:find_project] rendered_or_redirected.
Completed in 5ms (View: 0, DB: 0) | 404 Not Found [http://redmine.moonshadowmobile.net/issues.json?key=ee30bba95b162008370501028449fb81fa69380a]

- RAILS_ENV=production ruby script/about
About your application's environment
Ruby version 1.8.7 (x86_64-linux)
RubyGems version 1.3.5
Rack version 1.1
Rails version 2.3.5
Active Record version 2.3.5
Active Resource version 2.3.5
Action Mailer version 2.3.5
Active Support version 2.3.5
Edge Rails revision unknown
Application root /usr/share/redmine
Environment production
Database adapter mysql
Database schema version 20101114115359

Originally 0.9.4(I think) installed from tarball. Tarball version removed and db upgraded using normal 'apt-get install redmine' to version 1.0.1. Had a problem with POST /issues.json not accepting key based authentication. Upgraded system from lenny to squeeze and upgraded redmine to 1.1.2 in squeeze-backports.

Actions #1

Updated by Jean-Philippe Lang over 12 years ago

  • Status changed from New to Closed
  • Resolution set to Cant reproduce

Make sure you provide a valid project_id parameter. See Rest_Issues.

Actions #2

Updated by Ryan Olds over 12 years ago

I have tried using the id and identifier from the projects table in the database. The Rest_Issues page is unclear if the "project_id" property/tag should be the id or the identifier; The JSON example uses the identifier and the XML example uses the id.

Here is an example of the request body:

{"issue":{"project_id":"momo","subject":"Testing error","priority_id":"3","tracker_id":"5","category_id":"3","description":"","custom_field_values":{"1":"2.9"}}}

Actions #3

Updated by Ryan Olds over 12 years ago

  • Status changed from Closed to Reopened
Actions #4

Updated by Jean-Philippe Lang over 12 years ago

I didn't see any issue/project_id parameter in your log above. Can you post the actual log (with log_level set to debug if possible).

Actions #5

Updated by Ryan Olds over 12 years ago

Please advise on how to do that. Searching "debug" on the wiki didn't yield any instructions. I'm not a Rails developer.

Actions #6

Updated by Ryan Olds over 12 years ago

Processing IssuesController#create to json (for ... at 2011-08-01 17:09:07) [POST]
Parameters: {"format"=>"json", "action"=>"create", "controller"=>"issues", "key"=>"..."}
SQL (0.2ms) SELECT max(`settings`.updated_on) AS max_updated_on FROM `settings`
Token Load (0.2ms) SELECT * FROM `tokens` WHERE (`tokens`.`action` = 'api' AND `tokens`.`value` = '...') LIMIT 1
User Load (0.9ms) SELECT * FROM `users` WHERE (`users`.`id` = 14) AND ( (`users`.`type` = 'User' OR `users`.`type` = 'AnonymousUser' ) )
Filter chain halted as [:find_project] rendered_or_redirected.
Completed in 193ms (View: 0, DB: 1) | 404 Not Found [http://.../issues.json?key=...]

It really appears that it isn't consuming the body I'm sending. Are their any specific headers I need to be sending? At the moment I'm sending Content-Type: application/json.

Actions #7

Updated by Nathan Else over 12 years ago

Also getting this error:

Processing IssuesController#create to xml (for 188.39.53.42 at 2011-08-10 05:29:23) [POST]
  Parameters: {"format"=>"xml", "action"=>"create", "controller"=>"issues", "redmineissue"=>{"project_id"=>"gems", "subject"=>"XML REST API"}}
  SQL (1.4ms)   SELECT max("settings".updated_on) AS max_updated_on FROM "settings" 
  User Load (3.3ms)   SELECT * FROM "users" WHERE ( login = E'admin') AND ( ("users"."type" = 'User' OR "users"."type" = 'AnonymousUser' ) ) LIMIT 1
  SQL (0.6ms)   BEGIN
  User Update (1.1ms)   UPDATE "users" SET "last_login_on" = '2011-08-10 05:29:23.201868', "updated_on" = '2011-08-10 05:29:23.203947' WHERE "id" = 1
  CustomField Load (2.7ms)   SELECT * FROM "custom_fields" WHERE (type = 'UserCustomField') ORDER BY position
  SQL (2.4ms)   COMMIT
Filter chain halted as [:find_project] rendered_or_redirected.
Completed in 24ms (View: 1, DB: 12) | 404 Not Found [http://redmine.seafast.com/issues.xml]
Actions #8

Updated by Nathan Else over 12 years ago

It is worth noting that I'm running on port 3000, it seems to do some then try and post it to the url without the port number.

Actions #9

Updated by Nathan Else over 12 years ago

Just to let you know it is finally working, here is the PHP code that was used:

                $params = '{"issue":{"project_id":"2","subject":"Testing error"}}';
                $ch = curl_init();
                curl_setopt ($ch, CURLOPT_POST, 1);
                curl_setopt($ch, CURLOPT_POSTFIELDS,  $params);
                curl_setopt ($ch, CURLOPT_HTTPHEADER, array ("Content-Type: application/json", "Length: " . strlen ($params)));
                curl_setopt ($ch, CURLOPT_USERPWD, "admin:password");

                curl_setopt ($ch, CURLOPT_URL, "http://your.redmine.com:3000/issues.json");
                curl_setopt ($ch, CURLOPT_MAXREDIRS, 3);
                curl_setopt ($ch, CURLOPT_FOLLOWLOCATION, 0);
                curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
                curl_setopt ($ch, CURLOPT_VERBOSE, 0);
                curl_setopt ($ch, CURLOPT_HEADER, 1);
                curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, 10);
                curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, 0);
                curl_setopt ($ch, CURLOPT_SSL_VERIFYHOST, 0);

                $a = curl_exec($ch);
                curl_close($ch);
Actions #10

Updated by Tiago Peralta over 12 years ago

I must say that i'm also having this very issue with issues.xml as well

Processing IssuesController#create to xml (for 10.0.4.86 at 2011-08-25 16:14:53) [POST]
Parameters: {"format"=>"xml", "action"=>"create", "controller"=>"issues", "issue"=>{"project_id"=>"49", "subject"=>"SVN Backup Script", "tracker_id"=>"2", "custom_fields"=>[{"id"=>"19", "value"=>"Não"}]}}
Filter chain halted as [:find_project] rendered_or_redirected.
Completed in 231ms (View: 0, DB: 143) | 404 Not Found [http://tracks.xxxxx.local/issues.xml]

Actions #11

Updated by Rens Admiraal over 12 years ago

I had the exact same problem for a serie of requests, and have been debugging it in 1.2, 1.1 and current trunk. In the end it turned out not to be a redmine issue. I tested the REST api using the REST Client plugin for Firefox. It did give this exact same error till I sent the Content-type text/xml (I used the XML format, but also the json format failed).

This is the request I used:

<issue>
<tracker_id>1</tracker_id>
<project_id>1</project_id>
<subject>Example</subject>
</issue>

From the redmine point of view I would suggest adding some kind of error handling checking the request on this type (if possible), but furthermore step 1 during debugging this error is checking the actual request (method, content-type, and so on). I hope this helps someone ;-)

Actions #12

Updated by Sean Russell about 12 years ago

Confirmed that this is still broken. The correct mime type for JSON data is "application/json", but this always returns a 404. If the content type is changed to "text/xml", then Redmine does try to process the payload.

Tested with curl:

curl -H Content-Type:text/xml -H X-Redmine-API-Key:xxxxxxxxxxxxxxxxxxxxxxxxxxx -d payload.txt -v http://xxxxxxxxxxxxxxxxxxx.net/issues.json

Gives an internal error; any other content type (application/json, text/json) generates a 404.

Actions #13

Updated by Jean-Philippe Lang about 12 years ago

Test done on redmine 1.3.1:

curl -v -H "Content-Type: application/json" -X POST --data "@issue.json" -u foo:password http://localhost:3000/issues.json
* About to connect() to localhost port 3000 (#0)
*   Trying 127.0.0.1... connected
* Connected to localhost (127.0.0.1) port 3000 (#0)
* Server auth using Basic with user 'foo'
> POST /issues.json HTTP/1.1
> Authorization: Basic xxxxxxxxxxxxxxxxx=
> User-Agent: curl/7.21.2 (i386-pc-win32) libcurl/7.21.2 OpenSSL/0.9.8o zlib/1.2.5
> Host: localhost:3000
> Accept: */*
> Content-Type: application/json
> Content-Length: 64
>
< HTTP/1.1 201 Created
< Location: http://localhost:3000/issues/10158
< Connection: Keep-Alive
< Content-Type: application/json; charset=utf-8
< Date: Wed, 08 Feb 2012 21:59:12 GMT
< Server: WEBrick/1.3.1 (Ruby/1.8.7/2011-06-30)
< X-Runtime: 220
< Content-Length: 434
< Cache-Control: no-cache
< Set-Cookie: autologin=; path=/; expires=Thu, 01-Jan-1970 00:00:00 GMT
< Set-Cookie: _redmine_session=BAh7BjoPc2Vzc2lvbl9pZCIlN2Q2Yzg3NDljYTA4OGVhOGRjM
DA5YmQxZTI2ZDJmMjI%3D--f0a084d5385bc10cfd01e25a998ea4110c397e1f; path=/; HttpOnl
y
<
{"issue":{"custom_fields":[{"value":"","name":"Affected version","id":1},{"value
":"","name":"Resolution","id":2}],"author":{"name":"firstname lastname","id":162
61},"status":{"name":"New","id":1},"subject":"subject123","tracker":{"name":"Def
ect","id":1},"created_on":"2012/02/08 22:59:12 +0100","done_ratio":0,"project":{
"name":"Redmine","id":1},"id":10158,"updated_on":"2012/02/08 22:59:12 +0100","pr
iority":{"name":"Normal","id":4}}}* Connection #0 to host localhost left intact
* Closing connection #0

I get a 201 response and the issue is created as expected.

The data file (issue.json) contains:

{
  "issue": {
    "project_id": 1,
    "subject": "subject123" 
  }
}
Actions #14

Updated by Ryan Olds about 12 years ago

I this was happening when doing key based authentication.

Actions #15

Updated by Ryan Olds about 12 years ago

*I believe this was

Actions #16

Updated by Scott Corscadden almost 12 years ago

I think I am seeing this (or a close copy), I'm running "Redmine 1.4.1.stable.9526 (MySQL)". For example IntelliJ's integration uses the following (simplified) method of access:

scottc: src scottc$ curl -v "https://my.server.com/projects/foo/issues.xml?key=OMITTED&per_page=50" 

Results:

* About to connect() to my.server.com port 443 (#0)
*   Trying 192.168.0.1...
* connected
* Connected to my.server.com (192.168.0.1) port 443 (#0)
* successfully set certificate verify locations:
*   CAfile: /my/wicked.crt
  CApath: none
* SSLv3, TLS handshake, Client hello (1):
* SSLv3, TLS handshake, Server hello (2):
* SSLv3, TLS handshake, CERT (11):
* SSLv3, TLS handshake, Server key exchange (12):
* SSLv3, TLS handshake, Server finished (14):
* SSLv3, TLS handshake, Client key exchange (16):
* SSLv3, TLS change cipher, Client hello (1):
* SSLv3, TLS handshake, Finished (20):
* SSLv3, TLS change cipher, Client hello (1):
* SSLv3, TLS handshake, Finished (20):
* SSL connection using THE-FUNK
* Server certificate:
*      subject: serialNumber=ABCD; C=CA; ST=Ontario; L=London; O=scottness, inc.; OU=HQ; CN=*.not.a.com
*      start date: 2011-11-11 11:26:32 GMT
*      expire date: 2013-01-12 03:48:00 GMT
*      subjectAltName: my.server.com matched
*      issuer: C=US; O=GeoTrust, Inc.; CN=Scotts CA
*      SSL certificate verify ok.
> GET /projects/foo/issues.xml?key=OMITTED&per_page=50 HTTP/1.1
> User-Agent: curl/7.25.0 (x86_64-apple-darwin11.3.0) libcurl/7.25.0 OpenSSL/1.0.1b zlib/1.2.6 libidn/1.22
> Host: my.server.com:443
> Accept: */*
> 
< HTTP/1.1 404 Not Found
< Date: Thu, 03 May 2012 15:27:34 GMT
< Server: Apache/2.2.21 (Unix) mod_ssl/2.2.21 OpenSSL/0.9.8r DAV/2 PHP/5.3.8 SVN/1.6.17 Phusion_Passenger/3.0.7
< X-Powered-By: Phusion Passenger (mod_rails/mod_rack) 3.0.7
< X-Runtime: 4
< Cache-Control: no-cache
< Content-Length: 1
< Status: 404
< Cache-Control: max-age=60
< Expires: Thu, 03 May 2012 15:28:34 GMT
< MS-Author-Via: DAV
< Content-Type: application/xml; charset=utf-8
< 
* Connection #0 to host my.server.com left intact
 * Closing connection #0
* SSLv3, TLS alert, Client hello (1):

If I remove the API key, I correctly get a 401 Authorization Required. What's interesting is that the production.log file from redmine states:

Processing IssuesController#index to xml (for 10.0.1.1 at 2012-05-03 11:35:08) [GET]
  Parameters: {"format"=>"xml", "project_id"=>"foo", "action"=>"index", "controller"=>"issues", "per_page"=>"50", "key"=>"OMITTED"}
Filter chain halted as [:find_optional_project] rendered_or_redirected.
Completed in 4ms (View: 0, DB: 1) | 404 Not Found [https://my.server.com/projects/foo/issues.xml?key=OMITTED&per_page=50]

Whereas other requests seem to look like this:

Processing TimeTrackersController#render_menu (for 216.183.83.226 at 2012-05-03 11:35:03) [POST]
  Parameters: {"issue_id"=>"1762", "project_id"=>"22", "action"=>"render_menu", "authenticity_token"=>"YET-MORE-OMISSION", "controller"=>"time_trackers"}
Completed in 33ms (View: 26, DB: 3) | 200 OK [https://my.server.com/time_trackers/render_menu?issue_id=42&project_id=22]

Should project_id really be 'foo'? The other links seem to use numerics.

Actions #17

Updated by Jean-Philippe Lang almost 12 years ago

Scott Corscadden wrote:

I think I am seeing this (or a close copy), I'm running "Redmine 1.4.1.stable.9526 (MySQL)". For example IntelliJ's integration uses the following (simplified) method of access.

Your example with the API key as parameter works for me.

Should project_id really be 'foo'? The other links seem to use numerics.

Yes, if your project identifier is foo. But you can use numeric ids as well.

Actions #18

Updated by Scott Corscadden almost 12 years ago

Any idea how I could debug the fact that it does not work for me? There is obviously something different going on between yours and my setup. The IDE in question is doing the query (i.e., it's not easy to change) - what might be causing the 404 as I am pretty up to date on trunk, yet the access attempt clearly fails for me.

Actions #19

Updated by Jean-Philippe Lang almost 12 years ago

You can start by setting the Redmine log level to debug (uncomment the appropriate line in config/environment.rb and restart) then post the log.

Actions #20

Updated by Glen Holcomb over 11 years ago

I'm having a similar problem when trying to create an issue in JSON via the REST API.

Processing IssuesController#create to json (for 10.131.57.28 at 2012-09-07 10:32:02) [POST]
  Parameters: {"action"=>"create", "format"=>"json", "{\"issue\":{\"project_id\":\"1\",\"subject\":\"JSON Create Test\"}}"=>nil, "controller"=>"issues"}
  SQL (0.1ms)   SELECT max("settings".updated_on) AS max_updated_on FROM "settings" 
  AnonymousUser Load (0.2ms)   SELECT * FROM "users" WHERE ( ("users"."type" = 'AnonymousUser' ) ) LIMIT 1
Filter chain halted as [:find_project] rendered_or_redirected.
Completed in 2ms (View: 0, DB: 0) | 404 Not Found [http://10.192.2.23/redmine/issues.json]

It looks like the parameter hash is malformed but I have no idea why.

Actions #21

Updated by Glen Holcomb over 11 years ago

My apologies. I wasn't bothering to set the content-type header.

Actions #22

Updated by Roman Lukmanov about 11 years ago

same issue. I could provide you all logs.

request

curl -v -H "Content-Type: application/json" -X POST --data "@create.json" -H "X-Redmine-API-Key:[API key here]" http://[redmineurl]/issues.json

json
{
    "issue": {
    "project_id": "21",
    "subject": "Test issue" 
    }
}

answer from redmine

C:\Users\User1>curl -v -H "Content-Type: application/json" -X POST --data "@create.json" -H "X-Redmine-API-Key:[API key here]" http://[redmineurl]/issues.json
* About to connect() to [redmineurl] port 80 (#0)
*   Trying [redmineip]...
* connected
* Connected to [redmineurl] ([redmineip]) port 80 (#0)
> POST /issues.json HTTP/1.1
> User-Agent: curl/7.28.1
> Host: [redmineurl]
> Accept: */*
> Content-Type: application/json
> X-Redmine-API-Key:[API key]
> Content-Length: 68
>
* upload completely sent off: 68 out of 68 bytes
< HTTP/1.1 404 Not Found
< Server: nginx/1.2.4
< Date: Wed, 23 Jan 2013 14:55:50 GMT
< Content-Type: application/json; charset=utf-8
< Content-Length: 1
< Connection: keep-alive
< Cache-Control: no-cache
< X-Runtime: 8
< Set-Cookie: autologin=; path=/; expires=Thu, 01-Jan-1970 00:00:00 GMT
< Set-Cookie: _redmine_session=[session]; path=/; HttpOnly
<
 * Connection #0 to host [redmineurl] left intact
* Closing connection #0

in redmine's log

Processing IssuesController#create to json (for [ip] at 2013-01-23 19:05:04) [POST]
  Parameters: {"action"=>"create", "controller"=>"issues", "format"=>"json"}
  SQL (0.2ms)   SELECT max(`settings`.updated_on) AS max_updated_on FROM `settings`
  Token Load (0.1ms)   SELECT * FROM `tokens` WHERE (`tokens`.`value` = '[token]' AND `tokens`.`action` = 'api') LIMIT 1
  User Load (0.6ms)   SELECT * FROM `users` WHERE (`users`.`id` = 78) AND ( (`users`.`type` = 'User' OR `users`.`type` = 'AnonymousUser' ) )
Filter chain halted as [:find_project] rendered_or_redirected.
Completed in 7ms (View: 0, DB: 1) | 404 Not Found [http://[redmineurl]/issues.json]
Actions #23

Updated by Konstantin Manna over 9 years ago

Problem still exists in 2.5. Can reproduce with same output as Roman Lukmanov
Any updates on this?

Actions #24

Updated by Jean-Philippe Lang over 9 years ago

Your log file shows that the JSON payload is not recognized/parsed by Rails. It can be due to malformed JSON data.

Processing IssuesController#create to json (for [ip] at 2013-01-23 19:05:04) [POST]
  Parameters: {"action"=>"create", "controller"=>"issues", "format"=>"json"}

You should get something like:

Started POST "/issues.json" for 127.0.0.1 at 2014-10-05 21:00:23 +0200
Processing by IssuesController#create as JSON
  Parameters: {"issue"=>{"project_id"=>"1", "subject"=>"Test issue"}}

I can't tell why your request is not properly parsed but the problem is not on the Redmine side.
Please attach the exact JSON file that you send with your request.

Actions #25

Updated by Kevin Neumeyer over 9 years ago

I was affected by this issue too and I discovered that it only occurs if you pass an invalid project_id or no project_id, can someone confirm this?

If you pass a valid project_id it works for me tested using HttParty and ActiveResource.

Actions #26

Updated by Steve P almost 9 years ago

I had a similar error coming up in my Redmine log while using the Issue Tracker for Outlook addin for Microsoft Outlook.

In this particular scenario (see here for details) the web servers (puma/thin/unicorn) weren't handling the 'chunked-encoding' HTTP header correctly and were still waiting on the 'content-length' header. They don't appear to send out the correct 411 response nor process the chunked encoding request correctly.

Using nginx in front of these or using Apache2 fixed the issue.

Actions #27

Updated by Go MAEDA about 7 years ago

  • Category set to REST API
Actions #28

Updated by Go MAEDA about 2 months ago

  • Status changed from Reopened to Closed

Closing this issue as not reproducible.

Actions

Also available in: Atom PDF