Project

General

Profile

Actions

Defect #4795

closed

REST Api for Issues returns HTML

Added by Hannes Horneber almost 15 years ago. Updated almost 15 years ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Category:
Issues
Target version:
-
Start date:
2010-02-10
Due date:
% Done:

0%

Estimated time:
Resolution:
Invalid
Affected version:

Description

Calling the REST /issues.xml like described in the documentation returns an invalid html code.
No XML is returned at all.
I am using the github master branch (version 0.9.2-dev) in order to test the REST api.

Actions #1

Updated by Jean-Philippe Lang almost 15 years ago

Can't reproduce, please give some details.

Actions #2

Updated by Hannes Horneber almost 15 years ago

Ok, sorry...
I tested the REST API with the script you described here Rest_api_with_ruby. Then I get this error (only the relevant last snippet posted here):

2.3.5/lib/active_resource/formats/xml_format.rb:19:in `decode’ 
/Library/Ruby/Gems/1.8/gems/activeresource-2.3.5/lib/active_resource/connection.rb:138:in `get’ 
/Library/Ruby/Gems/1.8/gems/activeresource-2.3.5/lib/active_resource/base.rb:639:in `find_every’ 
/Library/Ruby/Gems/1.8/gems/activeresource-2.3.5/lib/active_resource/base.rb:582:in `find’ 
/Users/hannes/Desktop/rpc_test.rb:12 ... attempted adding second root element to document 
Line: Position: Last 80 unconsumed characters: <div style="margin:0;padding:0;display:inline"><input name=„authenticity_token“...

The last line seems to tell me, that the code returned is html, not xml.
If I call the /issues.xml URL using my browser the source code is html too. The html in it is some input-form for an issue, but no xml at all.
The first lines in the html after the script-tag are:
<table width="100%"> 
<tr> 
<td> 
<table> 

    <tr  id="tr_status_id" class="filter"> 
    <td style="width:200px;"> 
        <input checked="checked" id="cb_status_id" name="fields[]" onclick="toggle_filter('status_id');" type="checkbox" value="status_id" /> 
        <label for="cb_status_id">Status</label> 
    </td>... 

Perhaps some route is broken?
If I try to add an issue using the code from the ruby REST example the problem persists, although the issue gets added.

Actions #3

Updated by Jean-Philippe Lang almost 15 years ago

Can not reproduce with a fresh trunk.

Actions #4

Updated by Hannes Horneber almost 15 years ago

Ok, I’ve just downloaded a fresh trunk and only did transfer the database without any plugins. This worked great.
And than I added all my plugins and of course as the last one I added the redmine_subtasks plugin. After adding
this the error appears. So it has something to do with the subtasks plugin and obviously not with redmine itself.
Sorry for bothering!

Actions #5

Updated by Jean-Philippe Lang almost 15 years ago

  • Status changed from New to Closed
  • Resolution set to Invalid

OK, thanks for the feedback.

Actions #6

Updated by Robert Gruendler almost 15 years ago

i'm experiencing the same problem with the subtasks plugin, and created a ticket for the plugin author at:

http://github.com/hron/redmine_subtasks/issues/#issue/20

Is there any workaround except uninstalling the plugin right now?

Actions #7

Updated by Felix Schäfer almost 15 years ago

Robert, I just had a very succinct look, but I think you could get the xml view to work by just adding format.xml { render :layout => false } in the respond_to do |format| … end block in line 129 of app/controllers/issues_controller.rb in the plugin. That should yield the stock xml view, i.e. without any of the subtasks or anything. If you need those, you will need to copy app/views/issues/show.xml.builder to the plugin and tweak it to your liking.

Actions #8

Updated by Robert Gruendler almost 15 years ago

thanks for your tip. i've tried what you suggested, but i still get the html instead of xml:

    <h2>Tickets</h2>

    <form action="/queries/new" id="query_form" method="post"><div style="margin:0;padding:0;display:inline"><input name="authenticity_token" type="hidden" value="LYC3qS9jT7MYS8+CgHjyiC4aOct+Vk6iUbkZInkUNSY=" /></div>

        <div id="query_form_content">
    <fieldset id="filters"><legend>Filter</legend>
    <script type="text/javascript">
//<![CDATA[
function add_filter() {
    select = $('add_filter_select');
    field = select.value
    Element.show('tr_' +  field);
    check_box = $('cb_' + field);
    check_box.checked = true;
    toggle_filter(field);
    select.selectedIndex = 0;

    for (i=0; i<select.options.length; i++) {
        if (select.options[i].value == field) {
            select.options[i].disabled = true;
        }    
    }
}

function toggle_filter(field) {
    check_box = $('cb_' + field);

    if (check_box.checked) {
        Element.show("operators_" + field);
        toggle_operator(field);
    } else {
        Element.hide("operators_" + field);
        Element.hide("div_values_" + field);
  }
}
...

the modified in issues_controller.rb looks like this now:

respond_to do |format|
      format.html { render :template => 'issues/show.rhtml',
                           :layout => !request.xhr? }
      format.atom { render :action => 'changes',
                           :layout => false,
                           :content_type => 'application/atom+xml' }
      format.pdf  { send_data(issue_to_pdf(@issue),
                              :type => 'application/pdf',
                              :filename => "#{@project.identifier}-#{@issue.id}.pdf") }
      format.xml { render :layout => false }
    end

i've tried to add "content_type => 'text/xml'", but that didn't work either.

Also, i've copied the show.xml.builder over to the plugin directory, which didn't help too.

Am i missing something?

Actions #9

Updated by Felix Schäfer almost 15 years ago

Ah, just noticed what I posted above should fix the view of an individual issue, not of the ticket list, sorry :-) Anyway, /issue/6.xml should work, I'll have a look at the issue list later.

Actions #10

Updated by Felix Schäfer almost 15 years ago

The issue list is a little trickier. Could you check if you can download the issue list as a pdf and/or csv?

Actions #11

Updated by Robert Gruendler almost 15 years ago

pdf/csv/atom works fine. issues.xml returns html instead of xml.

Actions #12

Updated by Felix Schäfer almost 15 years ago

Dang, I had hoped I had put my finger on the problem. I'm sorry but I have no ideas left short from installing everything in a test environment, which I don't have time to, you will have to wait for the plugin author to correct the problem.

Actions #13

Updated by Robert Gruendler almost 15 years ago

no problem, thanks for your time anyway. not sure if the plugin author is working on issues right now.

i'm not a ruby developer myself, but there's one in our company. if he can find a quick and dirty workaround, i'll post it here.

Actions #14

Updated by Eric Davis almost 15 years ago

FYI: I have the REST API enabled for demo.redmine.org so you can use that for testing. It's a fairly recent version of trunk with only a few basic plugins for managing the site.

http://demo.redmine.org/issues/12436.xml
Actions

Also available in: Atom PDF