Feature #6823

REST API for time tracker.

Added by Vladimir Menshakov about 7 years ago. Updated over 6 years ago.

Status:ClosedStart date:2010-11-03
Priority:NormalDue date:
Assignee:-% Done:

0%

Category:REST API
Target version:1.1.0
Resolution:Fixed

Associated revisions

Revision 4461
Added by Jean-Philippe Lang almost 7 years ago

Adds REST API for TimeEntries (#6823).

History

#1 Updated by Jean-Philippe Lang about 7 years ago

  • Category set to REST API

#2 Updated by Vladimir Menshakov about 7 years ago

any chance to have it? :(

#3 Updated by Jean-Philippe Lang about 7 years ago

I think it won't be part of 1.1 but this is a must have.

#4 Updated by Yohann Monnier almost 7 years ago

I think so !

I really need it, even if it just add a time entry and nothing more.

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

  • Target version set to 1.1.0

#6 Updated by Jean-Philippe Lang almost 7 years ago

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

Added in r4461.

#7 Updated by Yohann Monnier almost 7 years ago

  • Status changed from Closed to Reopened

I have a problem using it :

Class with activeresource

# Timelog model rbot side
class ::TimeEntry < ::ActiveResource::Base
    self.element_name = 'time_entry'
    self.collection_name = 'time_entries'        
    self.proxy = ''
    self.timeout = 5
end

Code calling it

            ::TimeEntry.site ="http://myredmine" 
            ::TimeEntry.user = "myuser" 
            ::TimeEntry.password = "mypass" 
            newtimelog = TimeEntry.new(:issue_id => 7, :comments => "up", :activity_id =>9, :hours => "3h30")
            if newtimelog.save
                m.reply "it's ok" 
            else
                m.reply "it failed" 
            end

I get an error on this line : "if newtimelog.save"

undefined method `path' for nil:NilClass

 ["/usr/lib/ruby/1.8/active_resource/base.rb:410:in `prefix'", "/usr/lib/ruby/1.8/active_resource/base.rb:420:in `prefix_source'", "/usr/lib/ruby/1.8/active_resource/base.rb:684:in `prefix_parameters'", "/usr/lib/ruby/1.8/active_resource/base.rb:699:in `split_options'", "/usr/lib/ruby/1.8/active_resource/base.rb:697:in `each'", "/usr/lib/ruby/1.8/active_resource/base.rb:697:in `split_options'", "/usr/lib/ruby/1.8/active_resource/base.rb:1141:in

...

The new updated method for Issue use the same kind of routes and work very well.

I think i'm right on the way to use it, but i may be wrong and it could come from my code..

#8 Updated by Jean-Philippe Lang almost 7 years ago

  • Status changed from Reopened to Closed

I can not reproduce this problem and it happens on the client side.
The following code works just fine:

class TimeEntry < ActiveResource::Base
  self.site = 'http://localhost:3000'
  self.user = 'xxx'
  self.password = 'xxxxxx'
end

time = TimeEntry.new(:issue_id => 1, :hours => 2.3, :activity_id => 8, :spent_on => Date.today)
if time.save
  puts time.id
else
  pp time.errors
end

Please open another ticket if there is someting wrong with the API.

#9 Updated by Anonymous over 6 years ago

Can you with this api get time entries for specific day (today, yesterday, 2011-02-01), month (this, last) or between range of dates?

#10 Updated by Anonymous over 6 years ago

Never mind - you can, just use from and to parameters.

Also available in: Atom PDF