Project

General

Profile

Actions

Feature #6779

closed

Project JSON API

Added by Patrick Logé over 13 years ago. Updated over 13 years ago.

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

0%

Estimated time:
Resolution:
Fixed

Description

I doesn't seem to be possible to get projects as JSON
I did add this

  def index
    respond_to do |format|
      >>>>>>> format.json { render :text => Project.visible.find(:all, :order => 'lft').to_json, :layout => false }
      format.html { 
        @projects = Project.visible.find(:all, :order => 'lft') 
      }
      format.xml  {
        @projects = Project.visible.find(:all, :order => 'lft')
      }
      format.atom {
        projects = Project.visible.find(:all, :order => 'created_on DESC',
                                              :limit => Setting.feeds_limit.to_i)
        render_feed(projects, :title => "#{Setting.app_title}: #{l(:label_project_latest)}")
      }
    end
  end


to make it work

in the

Actions #1

Updated by Terence Mill over 13 years ago

nice alternative to complete redmine api, isn't it?

Actions #2

Updated by Jean-Philippe Lang over 13 years ago

  • Category changed from Projects to REST API
  • Target version set to 1.1.0
Actions #3

Updated by Eric Davis over 13 years ago

  • Subject changed from Projects with JSON to Project JSON API
  • Status changed from New to 7
  • Assignee set to Eric Davis
  • Priority changed from Low to Normal
  • Estimated time deleted (1.00 h)

Looks like the JSON api for projects was missed. I'm going to be reviewing the existing APIs and trying to clean them up over the next few weeks.

Actions #4

Updated by Patrick Logé over 13 years ago

Great thank!

Another info:

I wanted to use JSON to create a mobile application with Rhomobile
I had problems with the "Issues" REST interface because of illegal characters.
Rhomobile have a "Rho::AsyncHttp.get" method to consume JSON services.
My Redmine instance return something like

[{"start_date":"2010/09/10","deliverable_id":211,"estimated_hours":null,"priority_id":4,"created_on":"2010/09/10 16:56:56 
+0200","project_id":278,"root_id":8117,"lock_version":3,"lft":1,"fixed_version_id":113,"updated_on":"2010/09/13 20:47:44 
+0200","subject":"Adaptations","id":8117,"done_ratio":90,"assigned_to_id":11,"tracker_id":2,"category_id":null,"parent_id":null,
"due_date":null,"status_id":2,"description":"Hello, Anglais =\u003E","author_id":255,"rgt":2}]

I noticed a problem with the last character "\u003E". Once replace by "\u003e" (lowercase) it worked !!
So I did modify the Issues controller to return lowercase UTF8 entities.

 format.json { 
   j = @issues.to_json
   j.gsub!(/(u00)(.?)(.?)/){|n|  n.downcase}
   render :text => j, :layout => false 
 }

instead of
  format.json { render :text => @issues.to_json, :layout => false }

Strange....

I don't know where the problem comes from. I sent a ticket to Rhomobile

Actions #5

Updated by James Hardy over 13 years ago

Patrick Logé wrote:

I noticed a problem with the last character "\u003E". Once replace by "\u003e" (lowercase) it worked !!
So I did modify the Issues controller to return lowercase UTF8 entities.

From http://www.ietf.org/rfc/rfc4627.txt?number=4627 section 2.5 defining JSON, a unicode escape sequence is:

a reverse solidus, followed
by the lowercase letter u, followed by four hexadecimal digits that
encode the character's code point. The hexadecimal letters A though
F can be upper or lowercase.

so it would appear to be the client library which is at fault

Actions #6

Updated by Eric Davis over 13 years ago

  • Assignee deleted (Eric Davis)

I am stepping down from working on Redmine. If someone else is interesting in working on this issue, feel free to reassign it to them.

Eric Davis

Actions #7

Updated by Jean-Philippe Lang over 13 years ago

  • Status changed from 7 to Closed
  • Resolution set to Fixed

Projects JSON API available in r4456.

Actions

Also available in: Atom PDF