https://www.redmine.org/https://www.redmine.org/favicon.ico?16793021292010-08-02T00:11:46ZRedmineRedmine - Feature #5997: REST API should provide valid xml response with status for EVERY requesthttps://www.redmine.org/issues/5997?journal_id=188742010-08-02T00:11:46ZGerrit Kaiser
<ul></ul><p>The “status code” you're proposing is already provided by HTTP. To detect non-existing queries for instance, you could check for HTTP Status 404.</p> Redmine - Feature #5997: REST API should provide valid xml response with status for EVERY requesthttps://www.redmine.org/issues/5997?journal_id=190272010-08-06T00:06:12ZEric Davis
<ul><li><strong>Status</strong> changed from <i>New</i> to <i>Closed</i></li><li><strong>Resolution</strong> set to <i>Wont fix</i></li></ul><p>When using the rest API you need to check the HTTP status code first. Making every request return a 200 response and embedding the status code into the XML body is just duplicating the HTTP standards.</p>
<p>In your Java program, you should be able to catch the 400 status codes and handle it in code (e.g. retry, show message to user). Same for the server error codes (500).</p> Redmine - Feature #5997: REST API should provide valid xml response with status for EVERY requesthttps://www.redmine.org/issues/5997?journal_id=190312010-08-06T00:13:39ZAlex Last
<ul></ul><p>Agreed, many of these situations can be handled by HTTP status reports, but I'm not sure if the REST API provides meaningful error messages in addition to the HTTP response code (like "parameter XX can be ... but you provided .....", "project with id ... can't be found" or whatever).</p> Redmine - Feature #5997: REST API should provide valid xml response with status for EVERY requesthttps://www.redmine.org/issues/5997?journal_id=190772010-08-06T16:41:32ZEric Davis
<ul></ul><p>Some responses will. For example if you try to create an issue but are missing fields, an array of errors should be returned.</p> Redmine - Feature #5997: REST API should provide valid xml response with status for EVERY requesthttps://www.redmine.org/issues/5997?journal_id=190792010-08-06T16:44:35ZAlex Last
<ul></ul><p>good, thanks. one of the reasons why I submitted this request is because I was frustrated with creating issues via the REST API (I posted a question here: <a class="external" href="http://www.redmine.org/boards/2/topics/16260">http://www.redmine.org/boards/2/topics/16260</a> ).<br />The error message returned by Redmine is:<br /><pre>
Resp Code:405
Resp Message:Method Not Allowed
</pre></p>
<p>which is very frustrating - no idea what to do with it.</p> Redmine - Feature #5997: REST API should provide valid xml response with status for EVERY requesthttps://www.redmine.org/issues/5997?journal_id=190892010-08-06T22:54:59ZEric Davis
<ul></ul><p>Alexey Skor wrote:</p>
<blockquote>
<p>which is very frustrating - no idea what to do with it.</p>
</blockquote>
<p>Anytime you get a 400 or 500 series HTTP status code you need to look up what they mean. In this case (405), you are using the wrong HTTP verb, e.g. GET instead of POST.</p>
<p>Reference: <a class="external" href="http://en.wikipedia.org/wiki/List_of_HTTP_status_codes#4xx_Client_Error">http://en.wikipedia.org/wiki/List_of_HTTP_status_codes#4xx_Client_Error</a></p> Redmine - Feature #5997: REST API should provide valid xml response with status for EVERY requesthttps://www.redmine.org/issues/5997?journal_id=190902010-08-07T00:01:34ZAlex Last
<ul></ul><p>I understand that, but I'm using "POST /issues.xml" as Redmine REST API webpage describes:<br /><a class="external" href="http://www.redmine.org/wiki/redmine/Rest_Issues">http://www.redmine.org/wiki/redmine/Rest_Issues</a><br /><pre>
Creating an issue
POST /issues.xml
</pre><br />(see the code provided in that forum topic) - and Redmine complains that only GET is allowed. <br />so I suspect that I'm not building the request right (almost sure about this) and I should get a real explanation from Redmine instead of "only get is allowed".</p> Redmine - Feature #5997: REST API should provide valid xml response with status for EVERY requesthttps://www.redmine.org/issues/5997?journal_id=190932010-08-07T11:49:11ZFelix Schäfer
<ul></ul><p>Alexey Skor wrote:</p>
<blockquote>
<p>I should get a real explanation from Redmine</p>
</blockquote>
<p>Everything more than "go read the docs" would require envisioning a lot of possible wrong requests you could send it and the corresponding fix, so: no. You can read in your development logs (you do develop your application against a redmine in development mode, right?) at which point redmine borks. In that case: <code>POST /issues.xml</code>, where's the API key needed to authenticate you? (unless anonymous can create issues, of course).</p> Redmine - Feature #5997: REST API should provide valid xml response with status for EVERY requesthttps://www.redmine.org/issues/5997?journal_id=190942010-08-07T11:50:42ZFelix Schäfer
<ul></ul><p>Felix Schäfer wrote:</p>
<blockquote>
<p>In that case: <code>POST /issues.xml</code>, where's the API key needed to authenticate you? (unless anonymous can create issues, of course).</p>
</blockquote>
<p>Ok, forget about that part, just noticed you did call them with the key.</p> Redmine - Feature #5997: REST API should provide valid xml response with status for EVERY requesthttps://www.redmine.org/issues/5997?journal_id=191752010-08-10T00:35:33ZAlex Last
<ul></ul><p>I'm still stuck with this "POST" request for issues creation. Does anyone has an example of valid HTTP POST request for this? I don't need Java code, just a request body itself is fine.</p> Redmine - Feature #5997: REST API should provide valid xml response with status for EVERY requesthttps://www.redmine.org/issues/5997?journal_id=192942010-08-12T23:37:27ZEric Davis
<ul></ul><p>Alexey Skor wrote:</p>
<blockquote>
<p>I'm still stuck with this "POST" request for issues creation. Does anyone has an example of valid HTTP POST request for this? I don't need Java code, just a request body itself is fine.</p>
</blockquote>
<p>One with username and password, one with an API key:</p>
<pre>
$ curl -X POST -H "Content-Type: text/xml" -d "<issue><subject>api</subject><project_id>weimann3</project_id></issue>" http://admin:password@redmine.acheron/issues.xml
<?xml version="1.0" encoding="UTF-8"?>
<issue>
<id>226</id>
<project name="Customer-focused analyzing inf" id="4"/>
<tracker name="Bug" id="1"/>
<status name="New" id="1"/>
<priority name="Normal" id="4"/>
<author name="Eric Davis" id="1"/>
<subject>api</subject>
<description></description>
<start_date>2010-08-12</start_date>
<due_date></due_date>
<done_ratio>0</done_ratio>
<estimated_hours></estimated_hours>
<spent_hours>0.0</spent_hours>
<created_on>Thu Aug 12 23:37:30 +0000 2010</created_on>
<updated_on>Thu Aug 12 23:37:30 +0000 2010</updated_on>
<relations>
</relations>
</issue>
</pre>
<pre>
$ curl -X POST -H "Content-Type: text/xml" -d "<issue><subject>api</subject><project_id>weimann3</project_id></issue>" http://8e8dc0e6a24a95b228a3c046b9e7fe4be3411412:X@redmine.acheron/issues.xml
<?xml version="1.0" encoding="UTF-8"?>
<issue>
<id>227</id>
<project name="Customer-focused analyzing inf" id="4"/>
<tracker name="Bug" id="1"/>
<status name="New" id="1"/>
<priority name="Normal" id="4"/>
<author name="Eric Davis" id="1"/>
<subject>api</subject>
<description></description>
<start_date>2010-08-12</start_date>
<due_date></due_date>
<done_ratio>0</done_ratio>
<estimated_hours></estimated_hours>
<spent_hours>0.0</spent_hours>
<created_on>Thu Aug 12 23:38:50 +0000 2010</created_on>
<updated_on>Thu Aug 12 23:38:50 +0000 2010</updated_on>
<relations>
</relations>
</issue>
</pre> Redmine - Feature #5997: REST API should provide valid xml response with status for EVERY requesthttps://www.redmine.org/issues/5997?journal_id=193152010-08-13T04:50:14ZAlex Last
<ul></ul><p>thanks a lot. <br />a question: in this sample URL<br /><pre>
http://8e8dc0e6a24a95b228a3c046b9e7fe4be3411412:X@redmine.acheron/issues.xml
</pre></p>
<p>- does ":X@" stand for some value I need to put or it must be exactly ":X@" in the url (which didn't work for me)?</p>
<p>btw, this is not very secure to send api key in the URL. moving it inside the request body would be much better if HTTPS connection is used.</p> Redmine - Feature #5997: REST API should provide valid xml response with status for EVERY requesthttps://www.redmine.org/issues/5997?journal_id=193252010-08-13T09:32:20ZFelix Schäfer
<ul></ul><p>Alexey Skor wrote:</p>
<blockquote>
<p>- does ":X@" stand for some value I need to put or it must be exactly ":X@" in the url (which didn't work for me)?</p>
</blockquote>
<p>It can be whatever value you want, IIRC you can give the key as username and anything as password.</p>
<blockquote>
<p>btw, this is not very secure to send api key in the URL. moving it inside the request body would be much better if HTTPS connection is used.</p>
</blockquote>
<p>No, SSL/TLS encryption works at a lower level in the OSI model, i.e. the whole HTTP part of an https connection is completely encrypted.</p> Redmine - Feature #5997: REST API should provide valid xml response with status for EVERY requesthttps://www.redmine.org/issues/5997?journal_id=194372010-08-17T00:46:34ZAlex Last
<ul></ul><p>tried</p>
<blockquote>
<p>curl -X POST -H "Content-Type: text/xml" -d "<issue><subject>api</subject><project_id>taskconnector-test</project_id></issue>" <a class="external" href="https://fc20e8f5f1885fc194b7b7865e6d6ce9a44a4b88:X@www.hostedredmine.com/issues.xml">https://fc20e8f5f1885fc194b7b7865e6d6ce9a44a4b88:X@www.hostedredmine.com/issues.xml</a></p>
</blockquote>
<p>- does not work for HTTPS connection (no response is shown for CURL, similar request from a Java program shows "401 not authorized").</p>
<p>at the same time similar request works fine with my local Redmine through HTTP.<br />is this some server configuration issue on <a class="external" href="http://www.hostedredmine.org">www.hostedredmine.org</a> or the request must be different in case of HTTPS protocol?</p> Redmine - Feature #5997: REST API should provide valid xml response with status for EVERY requesthttps://www.redmine.org/issues/5997?journal_id=196952010-08-25T09:08:34ZBrad Rushworth
<ul></ul><p>Alexey Skor wrote:</p>
<blockquote>
<p>is this some server configuration issue on <a class="external" href="http://www.hostedredmine.org">www.hostedredmine.org</a> or the request must be different in case of HTTPS protocol?</p>
</blockquote>
<p>See: <a class="external" href="http://www.redmine.org/boards/2/topics/16260#message-16787">http://www.redmine.org/boards/2/topics/16260#message-16787</a></p>