Feature #8180

Include project members in project API response

Added by Jakub Wolny almost 12 years ago. Updated about 11 years ago.

Status:ClosedStart date:2011-04-18
Priority:NormalDue date:
Assignee:-% Done:


Category:REST API
Target version:-


I am creating Chrome Extension to Redmine and need some informations from API.
I want to get one project data (/projects/project.xml) with associated users.
I have checked the source of show.api.rsb and as I understand this - there is only
posibility to get project data with associated trackers.

Related issues

Duplicates Redmine - Feature #7420: Rest API for projects members Closed 2011-01-24


#1 Updated by Jakub Wolny almost 12 years ago

In the end of show.api.rsb I have added and it seems to work:

api.array :members do
    @project.members.each do |member|
      api.member(:id => member.id, :name => member.name, :user => member.user_id)
  end if include_in_api_response?('members') 

#2 Updated by Jakub Wolny almost 12 years ago

I have improved it a little bit:

 api.array :members do
    @project.members.each do |member|     
      member.roles do |role|
        api.role(:role => role.id)
      api.member(:id => member.id, :name => member.name, :user => member.user_id, :login => member.user.login, :mail => member.user.mail, :roles => member.roles)
  end if include_in_api_response?('members') 

  api.array :memberroles do     
    @users_by_role.keys.sort.each do |role|     
      api.memberroles(:id => role.id, :name => role.name, :users => @users_by_role[role].sort)
  end if include_in_api_response?('memberroles') 

  api.array :roles do     
    @users_by_role.keys.sort.each do |role|
      api.roles(:id => role.id, :name => role.name)      
  end if include_in_api_response?('roles') 

So you can fetch members, roles and combined. I only do not know how to "in proper way" show only neccessary user fields (without e.g. password hash and salt)

#3 Updated by Edward Subraman almost 12 years ago

This is unrelated to this issue. How do I create a new project in this system?

#4 Updated by Jakub Wolny almost 12 years ago

@Edward Subraman: you can create a new project by making POST request, as it described here:

#5 Updated by Jean-Philippe Lang almost 12 years ago

  • Tracker changed from Defect to Feature
  • Subject changed from project with associated users to Include project members in project API response

#6 Updated by Jean-Philippe Lang about 11 years ago

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

See #7420. Memberships API is added for 1.4.

Also available in: Atom PDF