Feature #296

REST API

Added by Alessio Spadaro over 2 years ago. Updated 3 days ago.

Status:Assigned Start:
Priority:Normal Due date:
Assigned to:Eric Davis % Done:

60%

Category:-
Target version:-
Resolution:


Description

The subject has been touched in a few other request (importing from trac, svn hooks). Having such an API will enable
any kind of integration/import/export, i wrote a few examples of possible uses, just for reference:
- scm integration (such as svn hooks)
- ide integration (e.g. Mylar www.eclipse.org/mylar, TortoiseSVN, etc..)
- office integration
- tools for import/export
- build system integration (maven, ant, cruisecontrol, continuum, ...)

Maybe is it too early (i.e. the model is too "volatile" for now)?

rest.diff (6.1 KB) Markus Knittig, 2008-07-05 21:49


Related issues

related to Feature #1214 REST API for Issues New 2008-05-08
related to Feature #568 Let end user customer report Issue Closed
related to Feature #2925 Url to fetch changesets for a repository New 2009-03-07
related to Patch #1901 RESTful URLs for everything Reopened 2008-09-15
duplicated by Feature #725 Feature Request - Web Service Gateway Resolved 2008-02-22
duplicated by Feature #3317 API and iPhone app Closed 2009-05-07

History

Updated by Jean-Philippe Lang over 2 years ago

No, i don't think it would be too early. Main model objects (projects, issues, ...) are stable enough. Even if they may be extended in the future.
Could you briefly specify what you expect from this API in terms of entry points ? (eg. fecth issues, create an issue, ...)

Updated by Alessio Spadaro over 2 years ago

I think that a minimum requirement should be to have an API that give full access at the issue level. This means access issues (CRUD), all the related models at least in read only mode (issues categories, etc..) and query support. This should be fine for attaching a single project from an external entity and a good starting point to build other features once the API starts being used.

In other post (the one on the svn hooks) we briefly talk about security concerns, but thinking again it could be delayed (i.e. handled by the sysadmin). The only thing to consider is the user/s the service/s will be bound to

I hope to have some time to think about the issue and give a more detailed answer.

Regards

Updated by Tim Parkinson about 1 year ago

Can I also vote for an API please. I think it would open up a whole world of possibility for an already cool product.
I'm certainly thinking query, create and update issues. For instance I have in mind something that would allow feature items to be created from an RSpec file.

Updated by Maximilian Karasz about 1 year ago

It's only one of the minor points of the original request so i'm afraid i might be slightly off topic, but i have successfully connected Eclipse Mylyn with redmine via the Generic Web Repository Connector.
Even though it provides just a very basic integration with eclipse/mylyn i thought maybe the configuration would interest a couple of people since there is, to my knowledge, no dedicated connector for redmine yet. please contact me if you're interested in the configuration, maybe a wiki howto would be a good idea...

Updated by Mads Vestergaard about 1 year ago

Maximilian, this sounds interesting could you send me wome further details at mnv (at) coolsms.dk

Thanks in advance.

Updated by Mark Gallop about 1 year ago

+! for me. A REST API would be a very useful feature.

Updated by Martin Herr about 1 year ago

+1 Would like to build an Redmine-AIR-Client based on the REST API :)

Updated by Doug Raney about 1 year ago

+1 for REST API. Would like to see a SOAP 1.2 compliant interface. See issue #725

Updated by Christopher Hlubek about 1 year ago

+1 for REST API

What about JSON format for usage in AJAX / RIA applications? I think it wouldn't take much more effort to add a JSON output as an supplement to XML and it would integrate nicer and more efficient in JavaScript driven applications.

Updated by John Z about 1 year ago

Seems like this issue has had a lot of feedback and there are a lot of votes for a REST API. Though I would normally also vote for REST, we've been relying on Mantis (http://www.mantisbt.org/) as our gateway issue management solution for years. Though Redmine wants to replace Mantis, we like it too much to use anything else for awhile. We have about 100 projects in Mantis now.

Our business process would be to receive issues into Mantis, evaluate them, then pass the ones to be worked into Redmine. Mantis has a SOAP API. So I guess we'd really like to see a SOAP API, or some other mechanism to pass selected issues to Redmine from Mantis.

Of course this might involve a REST service from Mantis..

Updated by Wes Billman about 1 year ago

+1 for REST API

would really like to see a mylyn connector for eclipse!!

Updated by Dopin Ninja about 1 year ago

+1 for REST API
a mylyn connector for eclipse should be so nice!

Updated by Karl DeBisschop about 1 year ago

To the user who was able to set up the generic mylyn connector, Any chance of posting details?

I'd love to see a native connector - that seems to be the big thing that trac still has over redmine.

Updated by Jean-Philippe Lang about 1 year ago

I've just added an Howto on using the Mylyn generic connector: HowTo Mylyn

Updated by Karl DeBisschop about 1 year ago

Thanks for the HowTo. Unfortunately, it doesn't seem to work for me. I haven't found a way to diagnose the problem. I have a bit of a suspicion that the login isn't working because when I try to open the query in a browser it fails. But I don't have enough understanding of the mylyn connector to be sure that I'm interpreting that fact correctly.

Updated by Benjamin Eberlei about 1 year ago

Thank you very much for that HowTo, I guess the request for a fully featured Mylyn connector would have to go to the Mylyn development team.

I raise my hand for the REST/SOAP API though, because it would be very useful to integrate redmine into other applications in an consistent way. Propably now you would just access the Redmine Database structure and retrieve the information you need in another application. A consitently defined gateway would be much more useful.

Updated by Akira Matsuda about 1 year ago

+1 for REST API

I strongly long for this feature in order to replace my ugly sh script like this...
ruby ${REDMINE_HOME}/script/runner "Issue.create :tracker_id => 3, :project => Project.find_by_identifier('${PROJECT_NAME}'), :sub
ject => '${SUBJECT}', :description => '${DESCRIPTION}', :author => User.find_by_login('${USER_NAME}'), :start_date => Time.now" 

Updated by Eric Davis about 1 year ago

I would love this feature also but looking at this from a development point of view, it's a huge undertaking. What might be a better way to make progress is to break it into smaller parts. Since it sounds like an issue API is a common request, I created #1214 for the issues API.

Updated by Karl DeBisschop about 1 year ago

I have posted a video on youtube to go along with the HowTo Mylyn

Updated by Roger Hunwicks about 1 year ago

+1 for Mylyn integration here too.

We are using the Generic Web Connector, as per the wiki page (thanks for that) but proper integration would be better.

We evaluated Eventum before deciding on Redmine, and our approach to Mylyn integration was going to be to produce a XML-RPC interface that matched the Trac one (because it is open source) and then try to use the native Trac connector to talk to Eventum. We're not able to attempt this for Redmine because we are a PHP shop, but someone else might want to consider if this is feasible. We figured this approach was possible using our existing skills, whereas writing a native Mylyn connector wasn't.

We would also consider using a REST/SOAP/XML-RPC interface to write an integration between dotProject and Redmine (it currently has integrations for Eventum and Mantis) and between our existing in-house issue tracker and Redmine.

Thanks
Roger

Updated by Roger Hunwicks about 1 year ago

Jean-Philippe Lang wrote:

I've just added an Howto on using the Mylyn generic connector: HowTo Mylyn

Please can you update this page:

If you are accessing Redmine via a subdirectory, e.g. http://server.company.com/redmine (instead of http://redmine.company.com) then the setup is slightly different:
Server:                 http://www.company.com/directory -- Replace it with the URL of your Redmine instance
Query pattern:          <td class="subject">.*?<a href="/directory/issues/show/(\d+)">(.+?)</a></td> -- replace /directory as required

Note the /directory in the query pattern, which must match the directory path you access Redmine at.

Thanks
Roger

Updated by Markus Knittig about 1 year ago

+1
I'm also very interested in an Mylyn connector. The Generic Web Connector doesn't have enough features for me and the Generic SQL Connector is not flexible enough. I would help to develop one, but before that a API is needed. Unfortunaly I'm a Ruby newbie, but maybe this can help: http://www.xml.com/pub/a/2006/04/19/rest-on-rails.html

Updated by Markus Knittig 12 months ago

So, I've played a bit with REST and Redmine. It was quite easy to set up even for me as a Ruby newbie. I successfully deleted projects and created a issue with curl. Problems:
  • REST doesn't like cookies. Some kind of token authentication would be good. Maybe extend the RSS key authentication?
  • Rendering single objects like projects are easy. But rendering e.g. issues with journals, timelogs and attachments as XML is tricky.
  • Haven't thought about querying custom fields, enumerations, etc.

Updated by Markus Knittig 11 months ago

  • % Done changed from 0 to 10

Someone has already created a basic XML-RPC service for Redmine: http://sourceforge.net/projects/redmin-mylyncon/
I'm looking into that, because I don't think it's possible to get Redmine RESTful without some serious rewrites...

Updated by Eric Davis 11 months ago

Markus Knittig wrote:

So, I've played a bit with REST and Redmine. It was quite easy to set up even for me as a Ruby newbie. I successfully deleted projects and created a issue with curl. Problems:
  • REST doesn't like cookies. Some kind of token authentication would be good. Maybe extend the RSS key authentication?
  • Rendering single objects like projects are easy. But rendering e.g. issues with journals, timelogs and attachments as XML is tricky.
  • Haven't thought about querying custom fields, enumerations, etc.

Looks like a good start. If I get some time I can try to lend a hand, I have a few years experience with REST and Ruby on Rails. The Redmine controllers are pretty fat though so I'd see a lot of refactoring needed to get a good API interface. I'd image the API would be a good 1.0 feature with maybe a preview release in 0.9.

Updated by Markus Knittig 10 months ago

Eric Davis wrote:

The Redmine controllers are pretty fat though so I'd see a lot of refactoring needed to get a good API interface.

ACK. What's your option on this: http://e-haitham.blogspot.com/2008/06/restful-rails-paramparsers-and-xml.html
About authentication: I think OAuth looks like a good solution...

Updated by Markus Knittig 9 months ago

  • % Done changed from 10 to 30

So, I've forked Redmine from Eric on GitHub and have begun to work on a RESTful branch: http://github.com/mknittig/redmine/tree/restful
It's still a bit buggy, but I'm making good progress...

Updated by Gerrit Kaiser 9 months ago

I did some work on Redmine’s URL scheme that would help this. I made the URLs adhere to Rails’ (new) conventions as closely as possible (e.g. /project/ecookbook/{wiki}issues|activity} etc.

See Issue #1901

(I can’t seem to add that issue as proper “related issue”. How come?)

Updated by Markus Knittig 9 months ago

Gerrit Kaiser wrote:

I did some work on Redmine’s URL scheme that would help this. I made the URLs adhere to Rails’ (new) conventions as closely as possible (e.g. /project/ecookbook/{wiki}issues|activity} etc.

See Issue #1901

Looks like a good start, but I think using resources instead of connect is a better solution. I might use some of your tests if you don't mind...

Updated by Gerrit Kaiser 9 months ago

You’re welcome to grab whatever you like from the patch! But let’s think about it:

Sure using map.resources would greatly clean up the routes.rb file, but there would be no other gain than that.

On the other hand, using map.resources requires a complete refactoring of all of the controllers. Redmine doesn’t use named routes internally, relying on url_for params hashes everywhere instead. So using map.resources right away would also require you to check and possibly change all links and forms on the site, a daunting task especially considering Redmine’s spotty view test coverage.

Using equivalent conventional routes where appropriate like in my patch would allow you to create an external interface that is exactly like it should be. Then introducing named routes and using them everywhere, then refactoring the controllers (one by one) to follow Rails’s action conventions and finally switching to map.resources calls to generate the routes seems to me like a more viable migration path, especially considering the significant size of Redmine’s codebase.

Updated by Markus Knittig 9 months ago

Gerrit Kaiser wrote:

You’re welcome to grab whatever you like from the patch! But let’s think about it:

Sure using map.resources would greatly clean up the routes.rb file, but there would be no other gain than that.

You can use the path and url helpers that resources generates...

On the other hand, using map.resources requires a complete refactoring of all of the controllers. Redmine doesn’t use named routes internally, relying on url_for params hashes everywhere instead. So using map.resources right away would also require you to check and possibly change all links and forms on the site, a daunting task especially considering Redmine’s spotty view test coverage.

Good point...

Using equivalent conventional routes where appropriate like in my patch would allow you to create an external interface that is exactly like it should be. Then introducing named routes and using them everywhere, then refactoring the controllers (one by one) to follow Rails’s action conventions and finally switching to map.resources calls to generate the routes seems to me like a more viable migration path, especially considering the significant size of Redmine’s codebase.

Sound's like a good plan to me...

Updated by Eric Davis 9 months ago

Markus Knittig wrote:

So, I've forked Redmine from Eric on GitHub and have begun to work on a RESTful branch: http://github.com/mknittig/redmine/tree/restful It's still a bit buggy, but I'm making good progress...

Once you get it to good working state, send me a pull request and I'll see about merging it into core (or as a branch of core). With such a large change, I'd like to make sure there is a lot of test coverage.

Updated by Brian Palmer 9 months ago

Markus Knittig wrote:

  • REST doesn't like cookies. Some kind of token authentication would be good. Maybe extend the RSS key authentication?

Rather than token auth, why not just use HTTP BASIC auth? Rails 2.0 even has it baked in.

Updated by Markus Knittig 8 months ago

Eric Davis wrote:

Once you get it to good working state, send me a pull request and I'll see about merging it into core (or as a branch of core). With such a large change, I'd like to make sure there is a lot of test coverage.

I'm nearly ready with the principle work. Only two functional test fail ("ArgumentError: tried to create Proc object without a block") and I've no idea why, because they seem to work manually. Also the refactored controller code might sometimes be a bit hackish...
A branch would be fine. It should be merged when 0.8 is done.

Brian Palmer wrote:

Rather than token auth, why not just use HTTP BASIC auth? Rails 2.0 even has it baked in.

Yeah, that might be the simplest solution.

Updated by Eric Davis 8 months ago

Markus Knittig wrote:

I'm nearly ready with the principle work. Only two functional test fail ("ArgumentError: tried to create Proc object without a block") and I've no idea why, because they seem to work manually. Also the refactored controller code might sometimes be a bit hackish... A branch would be fine. It should be merged when 0.8 is done.

Great, I'm following you on GitHub so let me know once it's ready for some more stressful testing.

Jean-Philippe, how close are we to 0.8? If we still have a lot of time, it might be good to pull in the REST code into trunk and let it stabilize there. If 0.8 is coming up soon, it might be best to keep the REST out until post-release.

Updated by Markus Knittig 8 months ago

  • % Done changed from 30 to 60

So, finally all test pass, but there is still some refactoring to do. BTW: I've not refactored the wiki and the repository controllers and routes yet, because there routing is a bit complicated.
I'm playing around with Selenium for better test coverage (the current test methods don't really cover errors in views). Would it be OK to add the Selenium Rails Plugins to Redmine?
I've also started a new branch restful-ext where I add XML output to Redmine (plus HTTP Basic Authentication for REST Clients).

Updated by Jan Ivar Beddari 7 months ago

The work you are doing here Markus is really interesting, thanks and keep it up! Your progress is just inspiring, funny how you at 2008-06-29 posted that you were a Ruby newbie, well now where are we? ;-)

Updated by Patrick Naubert 5 months ago

+1

Updated by Eric Davis 5 months ago

I just commited support for REST urls in r2317. This is the first step towards an actual REST interface.

Updated by Markus Knittig 5 months ago

Just updated, looks great!

Updated by Eric Davis 4 months ago

  • Status changed from New to Assigned
  • Assigned to set to Eric Davis

Seeing as this issue has been around for such a long time with very little progress, I'm going to take it and see what I can do about it. I'm not promising it will be complete, just that it will be worked on. If anyone wants to help or send me patches I'd love the help. I'll be checking the patches here and the commits on GitHub.

And if you don't see REST, you now have a target someone to ask about it.

Updated by Markus Knittig 4 months ago

Eric Davis wrote:

Seeing as this issue has been around for such a long time with very little progress, I'm going to take it and see what I can do about it. I'm not promising it will be complete, just that it will be worked on. If anyone wants to help or send me patches I'd love the help. I'll be checking the patches here and the commits on GitHub.

Cool, I'll revisit my Redmine RESTful branch this weekend. IMO the main problem is the ugly controller refactoring. A Ruby/Rails Pro like you can probably do a much better job...

Updated by Yohann Monnier 2 months ago

I would like to use this Rest API to use Redmine's Tickets methods through webservice to make a link between

How it works ?

Has this work been merged with the main Trunk ?

Thank you for your work.

Yohann

Updated by Jens Goldhammer about 1 month ago

+1 for integrating it into the trunk

Updated by Oleg Lozinskij 19 days ago

+1

and another +1 for a good documentation (or at least wiki page with all mapped URLs)

Updated by Davide Ferrari 17 days ago

+1 to know about the status of Redmine APIs. lot of integration stuff could be done with this API in a cleaner way. Can you merge somehow in trunk, even if not 100% complete (but not giving errors, obviously).

TIA!

Updated by Piero Sartini 3 days ago

+1
right now it's hard to write connectors (thinking about IntelliJ and NetBeans).

Also available in: Atom PDF