Feature #8180
closed
Include project members in project API response
Added by Jakub Wolny over 13 years ago.
Updated almost 13 years ago.
Description
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.
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
end if include_in_api_response?('members')
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)
end
api.member(:id => member.id, :name => member.name, :user => member.user_id, :login => member.user.login, :mail => member.user.mail, :roles => member.roles)
end
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
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
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)
This is unrelated to this issue. How do I create a new project in this system?
- Tracker changed from Defect to Feature
- Subject changed from project with associated users to Include project members in project API response
- Status changed from New to Closed
- Resolution set to Duplicate
See #7420. Memberships API is added for 1.4.
Also available in: Atom
PDF