https://www.redmine.org/https://www.redmine.org/favicon.ico?16793021292012-07-13T14:05:01ZRedmineRedmine - Defect #11388: Updating a version through rest API returns invalid JSONhttps://www.redmine.org/issues/11388?journal_id=396512012-07-13T14:05:01ZEtienne Massip
<ul><li><strong>Category</strong> set to <i>REST API</i></li></ul> Redmine - Defect #11388: Updating a version through rest API returns invalid JSONhttps://www.redmine.org/issues/11388?journal_id=396532012-07-13T14:12:31ZEtienne Massip
<ul><li><strong>Target version</strong> set to <i>Candidate for next minor release</i></li></ul> Redmine - Defect #11388: Updating a version through rest API returns invalid JSONhttps://www.redmine.org/issues/11388?journal_id=396542012-07-13T14:32:41ZJean-Philippe Langjp_lang@yahoo.fr
<ul><li><strong>Target version</strong> changed from <i>Candidate for next minor release</i> to <i>Candidate for next major release</i></li></ul><p>Lets define the expected behaviour first.</p> Redmine - Defect #11388: Updating a version through rest API returns invalid JSONhttps://www.redmine.org/issues/11388?journal_id=396562012-07-13T14:48:18ZJean-Philippe Langjp_lang@yahoo.fr
<ul></ul><p>A more appropriate response should be a 204 response but I guess it could break some API clients. So I propose to respond with a 200 and an empty body. Should we keep the Content-Type as it is now?</p> Redmine - Defect #11388: Updating a version through rest API returns invalid JSONhttps://www.redmine.org/issues/11388?journal_id=396592012-07-13T15:15:10ZEtienne Massip
<ul></ul><p>There has been <a href="https://github.com/rails/rails/commit/0d3333257156544feba729ba28f6874d5a30d561" class="external">a related commit</a> in RoR (<a href="https://rails.lighthouseapp.com/projects/8994/tickets/5199-respond_with-returns-on-put-and-delete-verb" class="external">original LH ticket</a>) to return an empty object (because setting Content-Type and no body makes no sense either I guess).</p>
<p>After discussion, it was eventually overrided by <a href="https://github.com/rails/rails/commit/80768b739ed7e2053d85a01dd5fa60bde67aad9a" class="external">a new commit</a> setting the response code to <code>204</code> and setting the body back to an single space.</p>
<p>I would do the way Rails do.</p>
<p>Edit: not an empty string, a single space.</p> Redmine - Defect #11388: Updating a version through rest API returns invalid JSONhttps://www.redmine.org/issues/11388?journal_id=396672012-07-13T15:33:12ZJean-Philippe Langjp_lang@yahoo.fr
<ul></ul><p>The default Rails behaviour is now a <code>204 No Content</code> with a non-empty body, really?</p> Redmine - Defect #11388: Updating a version through rest API returns invalid JSONhttps://www.redmine.org/issues/11388?journal_id=396692012-07-13T15:50:45ZEtienne Massip
<ul></ul><p>Jean-Philippe Lang wrote:</p>
<blockquote>
<p>The default Rails behaviour is now a <code>204 No Content</code> with a non-empty body, really?</p>
</blockquote>
<p>Well, I did not test but that's what the code and commit say :D</p>
<pre>...
<code class="ruby syntaxhl"><span class="n">assert_equal</span> <span class="mi">204</span><span class="p">,</span> <span class="vi">@response</span><span class="p">.</span><span class="nf">status</span>
<span class="n">assert_equal</span> <span class="s2">" "</span><span class="p">,</span> <span class="vi">@response</span><span class="p">.</span><span class="nf">body</span>
</code>...</pre> Redmine - Defect #11388: Updating a version through rest API returns invalid JSONhttps://www.redmine.org/issues/11388?journal_id=396712012-07-13T16:00:39ZJean-Philippe Langjp_lang@yahoo.fr
<ul></ul><p>I have made a few tests with JQuery. It gives an error when responding with a one space response body indeed. But it seems to work fine with a 200 response and an empty body, even if the response Content-Type is set to text/json. It gives no error and returns null.</p>
<p>So I propose to just change the "one space" response body to an empty body.</p> Redmine - Defect #11388: Updating a version through rest API returns invalid JSONhttps://www.redmine.org/issues/11388?journal_id=396742012-07-13T16:18:33ZEtienne Massip
<ul></ul><p>Did you try with a <code>204</code> and a single space?</p> Redmine - Defect #11388: Updating a version through rest API returns invalid JSONhttps://www.redmine.org/issues/11388?journal_id=396762012-07-13T16:33:43ZJean-Philippe Langjp_lang@yahoo.fr
<ul></ul><p>No, but I really don't want to change the API behaviour in this way and break compatibility.</p> Redmine - Defect #11388: Updating a version through rest API returns invalid JSONhttps://www.redmine.org/issues/11388?journal_id=396772012-07-13T16:36:34ZJean-Philippe Langjp_lang@yahoo.fr
<ul></ul><p>Etienne Massip wrote:</p>
<blockquote>
<p>Did you try with a <code>204</code> and a single space?</p>
</blockquote>
<p>It seems to behave just like with an empty 200 response.</p> Redmine - Defect #11388: Updating a version through rest API returns invalid JSONhttps://www.redmine.org/issues/11388?journal_id=396782012-07-13T17:04:18ZEtienne Massip
<ul></ul><p>FTR, there exists a <a href="http://bugs.jquery.com/ticket/7099" class="external">jQuery bug</a> which has been closed.</p>
<p>Quote : <cite>An example of this is the 204 No Content status. The HTTP specification is unclear as to the inclusion of content-type. It does not forbid including it at any rate. <strong>But it does forbid the inclusion of a message-body.</strong></cite></p> Redmine - Defect #11388: Updating a version through rest API returns invalid JSONhttps://www.redmine.org/issues/11388?journal_id=396792012-07-13T17:05:21ZEtienne Massip
<ul></ul><p>Jean-Philippe Lang wrote:</p>
<blockquote>
<p>So I propose to just change the "one space" response body to an empty body.</p>
</blockquote>
<p>Agreed.</p> Redmine - Defect #11388: Updating a version through rest API returns invalid JSONhttps://www.redmine.org/issues/11388?journal_id=397012012-07-15T14:53:18ZJean-Philippe Langjp_lang@yahoo.fr
<ul><li><strong>Status</strong> changed from <i>New</i> to <i>Resolved</i></li><li><strong>Assignee</strong> set to <i>Jean-Philippe Lang</i></li><li><strong>Target version</strong> changed from <i>Candidate for next major release</i> to <i>2.0.4</i></li><li><strong>Resolution</strong> set to <i>Fixed</i></li></ul> Redmine - Defect #11388: Updating a version through rest API returns invalid JSONhttps://www.redmine.org/issues/11388?journal_id=399782012-07-26T17:09:58ZJean-Philippe Langjp_lang@yahoo.fr
<ul><li><strong>Status</strong> changed from <i>Resolved</i> to <i>Closed</i></li><li><strong>Target version</strong> changed from <i>2.0.4</i> to <i>2.1.0</i></li></ul><p>No feedback about the change, it will wait for 2.1.0.</p>