Comments (7)
Hi!
I can't reproduce neither first nor second error here, so:
-
Are you sure that
rm.time_entry.filter(from_date='2014-04-18', to_date='2014-04-18')
returns time entries in exact same order every time ? From the code you've posted we can't be sure thattes[0]
is the same time entry every time. -
I see at least 1 mistake, spent_on should be a date not a date time, so can you try set it to
rmte.spent_on='2014-04-18'
thought I don't receive an error which you receive, if I use a datetime I receive a validation error here. Can you print theresponse.status_code
andresponse.content
in redmine/init.py line 79
from python-redmine.
Here is the new output:
Python 2.7.5+ (default, Feb 27 2014, 19:37:08)
[GCC 4.8.1] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from redmine import Redmine
>>> rm = Redmine(url,key=api_key)
>>> tes = rm.time_entry.filter(from_date='2014-04-18', to_date='2014-04-18')
>>> te = tes[0]
==========
status_code:
200
Content:
{"time_entries":[{"id":4997,"project":{"id":154,"name":"MyPrj"},"user":{"id":93,"name":"Lorenzo Mele"},"activity":{"id":9,"name":"Development"},"hours":1.0,"comments":"prova","spent_on":"2014-04-18","created_on":"2014-04-18T22:34:01Z","updated_on":"2014-04-18T22:34:01Z","custom_fields":[{"id":9,"name":"Billable","value":"0"}]},{"id":4994,"project":{"id":154,"name":"MyPrj"},"user":{"id":97,"name":"John Doe"},"activity":{"id":9,"name":"Development"},"hours":4.0,"comments":"Analysis of EE-16...","spent_on":"2014-04-18","created_on":"2014-04-18T16:05:11Z","updated_on":"2014-04-18T22:32:26Z","custom_fields":[{"id":9,"name":"Billable","value":"1"}]},{"id":4993,"project":{"id":154,"name":"MyPrj"},"issue":{"id":5523},"user":{"id":97,"name":"John Doe"},"activity":{"id":9,"name":"Development"},"hours":4.0,"comments":"","spent_on":"2014-04-18","created_on":"2014-04-18T16:04:56Z","updated_on":"2014-04-18T16:04:56Z","custom_fields":[{"id":9,"name":"Billable","value":"1"}]}],"total_count":3,"offset":0,"limit":100}
==========
>>> te.id
4997
>>> te.comments
u'prova'
>>> te.comments = u'riprova'
>>> te.save()
==========
status_code:
200
Content:
{"time_entry":{"id":4997,"project":{"id":154,"name":"MyPrj"},"user":{"id":93,"name":"Lorenzo Mele"},"activity":{"id":9,"name":"Development"},"hours":1.0,"comments":"prova","spent_on":"2014-04-18","created_on":"2014-04-18T22:34:01Z","updated_on":"2014-04-18T22:34:01Z","custom_fields":[{"id":9,"name":"Billable","value":"0"}]}}
==========
True
>>> rmte = rm.time_entry.new()
>>> rmte.issue_id=5574
>>> rmte.spent_on='2014-04-18'
>>> rmte.hours=1
>>> rmte.save()
==========
status_code:
200
Content:
{"time_entries":[{"id":4997,"project":{"id":154,"name":"MyPrj"},"user":{"id":93,"name":"Lorenzo Mele"},"activity":{"id":9,"name":"Development"},"hours":1.0,"comments":"prova","spent_on":"2014-04-18","created_on":"2014-04-18T22:34:01Z","updated_on":"2014-04-18T22:34:01Z","custom_fields":[{"id":9,"name":"Billable","value":"0"}]},{"id":4994,"project":{"id":154,"name":"MyPrj"},"user":{"id":97,"name":"John Doe"},"activity":{"id":9,"name":"Development"},"hours":4.0,"comments":"Analysis of EE-16...","spent_on":"2014-04-18","created_on":"2014-04-18T16:05:11Z","updated_on":"2014-04-18T22:32:26Z","custom_fields":[{"id":9,"name":"Billable","value":"1"}]},{"id":4993,"project":{"id":154,"name":"MyPrj"},"issue":{"id":5523},"user":{"id":97,"name":"John Doe"},"activity":{"id":9,"name":"Development"},"hours":4.0,"comments":"","spent_on":"2014-04-18","created_on":"2014-04-18T16:04:56Z","updated_on":"2014-04-18T16:04:56Z","custom_fields":[{"id":9,"name":"Billable","value":"1"}]},{"id":4992,"project":{"id":154,"name":"MyPrj"},"issue":{"id":5523},"user":{"id":97,"name":"John Doe"},"activity":{"id":9,"name":"Development"},"hours":9.0,"comments":"","spent_on":"2014-04-17","created_on":"2014-04-17T17:19:49Z","updated_on":"2014-04-17T17:19:49Z","custom_fields":[{"id":9,"name":"Billable","value":"1"}]},{"id":4991,"project":{"id":141,"name":"Staff"},"issue":{"id":3672},"user":{"id":60,"name":"John Doe"},"activity":{"id":40,"name":"Other"},"hours":4.0,"comments":"Afternoon off.","spent_on":"2014-04-17","created_on":"2014-04-17T06:57:23Z","updated_on":"2014-04-17T06:57:23Z","custom_fields":[{"id":9,"name":"Billable","value":"1"}]},{"id":4988,"project":{"id":154,"name":"MyPrj"},"user":{"id":97,"name":"John Doe"},"activity":{"id":9,"name":"Development"},"hours":9.0,"comments":"#5544 - #5545 - #5547","spent_on":"2014-04-16","created_on":"2014-04-16T17:15:02Z","updated_on":"2014-04-16T17:15:02Z","custom_fields":[{"id":9,"name":"Billable","value":"1"}]},{"id":4987,"project":{"id":154,"name":"MyPrj"},"user":{"id":97,"name":"John Doe"},"activity":{"id":9,"name":"Development"},"hours":8.0,"comments":"Analysis of the next sprint","spent_on":"2014-04-15","created_on":"2014-04-15T16:14:55Z","updated_on":"2014-04-15T16:14:55Z","custom_fields":[{"id":9,"name":"Billable","value":"1"}]},{"id":4986,"project":{"id":154,"name":"MyPrj"},"issue":{"id":5333},"user":{"id":97,"name":"John Doe"},"activity":{"id":9,"name":"Development"},"hours":8.0,"comments":"Resolved various linkedin import problems","spent_on":"2014-04-14","created_on":"2014-04-14T16:36:03Z","updated_on":"2014-04-14T16:36:03Z","custom_fields":[{"id":9,"name":"Billable","value":"1"}]},{"id":4990,"project":{"id":141,"name":"Staff"},"issue":{"id":3672},"user":{"id":60,"name":"John Doe"},"activity":{"id":40,"name":"Other"},"hours":8.0,"comments":"Day off.","spent_on":"2014-04-11","created_on":"2014-04-17T06:56:47Z","updated_on":"2014-04-17T06:56:47Z","custom_fields":[{"id":9,"name":"Billable","value":"1"}]},{"id":4985,"project":{"id":154,"name":"MyPrj"},"issue":{"id":5457},"user":{"id":90,"name":"John Doe"},"activity":{"id":9,"name":"Development"},"hours":8.0,"comments":"Task #5457: Porting MyPrjIT/UK modifications into EE (EE-0)","spent_on":"2014-04-11","created_on":"2014-04-14T09:18:43Z","updated_on":"2014-04-14T09:18:43Z","custom_fields":[{"id":9,"name":"Billable","value":"1"}]},{"id":4981,"project":{"id":154,"name":"MyPrj"},"issue":{"id":5333},"user":{"id":97,"name":"John Doe"},"activity":{"id":9,"name":"Development"},"hours":10.0,"comments":"Added import of various dates, removed php Notices, now Education is editable","spent_on":"2014-04-11","created_on":"2014-04-11T17:55:16Z","updated_on":"2014-04-11T17:55:16Z","custom_fields":[{"id":9,"name":"Billable","value":"1"}]},{"id":4984,"project":{"id":154,"name":"MyPrj"},"issue":{"id":5457},"user":{"id":90,"name":"John Doe"},"activity":{"id":9,"name":"Development"},"hours":8.0,"comments":"Task #5457: Porting modifications into EE (EE-0)","spent_on":"2014-04-10","created_on":"2014-04-14T09:18:24Z","updated_on":"2014-04-14T09:18:24Z","custom_fields":[{"id":9,"name":"Billable","value":"1"}]},{"id":4980,"project":{"id":154,"name":"MyPrj"},"user":{"id":97,"name":"John Doe"},"activity":{"id":9,"name":"Development"},"hours":9.0,"comments":"Bug: inbox is different from local to DEV. Tested CRUD meeting","spent_on":"2014-04-10","created_on":"2014-04-11T07:20:54Z","updated_on":"2014-04-11T07:20:54Z","custom_fields":[{"id":9,"name":"Billable","value":"1"}]},{"id":4979,"project":{"id":33,"name":"Management"},"user":{"id":13,"name":"John Doe"},"activity":{"id":40,"name":"Other"},"hours":1.0,"comments":"Something","spent_on":"2014-04-10","created_on":"2014-04-10T06:12:50Z","updated_on":"2014-04-10T06:12:50Z","custom_fields":[{"id":9,"name":"Billable","value":"1"}]},{"id":4989,"project":{"id":141,"name":"Staff"},"issue":{"id":3672},"user":{"id":60,"name":"John Doe"},"activity":{"id":40,"name":"Other"},"hours":8.0,"comments":"Day off.","spent_on":"2014-04-09","created_on":"2014-04-17T06:56:30Z","updated_on":"2014-04-17T06:56:30Z","custom_fields":[{"id":9,"name":"Billable","value":"1"}]},{"id":4983,"project":{"id":154,"name":"MyPrj"},"issue":{"id":5457},"user":{"id":90,"name":"John Doe"},"activity":{"id":9,"name":"Development"},"hours":5.3,"comments":"Task #5457: Porting modifications into EE (EE-0)","spent_on":"2014-04-09","created_on":"2014-04-14T09:16:34Z","updated_on":"2014-04-14T09:17:57Z","custom_fields":[{"id":9,"name":"Billable","value":"1"}]},{"id":4982,"project":{"id":154,"name":"MyPrj"},"issue":{"id":5456},"user":{"id":90,"name":"John Doe"},"activity":{"id":9,"name":"Development"},"hours":2.3,"comments":" Task #5456: EE-10 Check visibility of user profile field","spent_on":"2014-04-09","created_on":"2014-04-14T09:15:04Z","updated_on":"2014-04-14T09:19:32Z","custom_fields":[{"id":9,"name":"Billable","value":"1"}]},{"id":4978,"project":{"id":154,"name":"MyPrj"},"issue":{"id":5454},"user":{"id":97,"name":"John Doe"},"activity":{"id":9,"name":"Development"},"hours":2.0,"comments":"Implemented","spent_on":"2014-04-09","created_on":"2014-04-09T16:29:50Z","updated_on":"2014-04-09T16:29:50Z","custom_fields":[{"id":9,"name":"Billable","value":"1"}]},{"id":4977,"project":{"id":154,"name":"MyPrj"},"issue":{"id":5455},"user":{"id":97,"name":"John Doe"},"activity":{"id":9,"name":"Development"},"hours":6.0,"comments":"Implemented","spent_on":"2014-04-09","created_on":"2014-04-09T16:29:35Z","updated_on":"2014-04-09T16:29:35Z","custom_fields":[{"id":9,"name":"Billable","value":"1"}]},{"id":4976,"project":{"id":154,"name":"MyPrj"},"issue":{"id":5334},"user":{"id":97,"name":"John Doe"},"activity":{"id":9,"name":"Development"},"hours":8.0,"comments":"Tested create user and company, create various issues, analyzed how to development some of these","spent_on":"2014-04-08","created_on":"2014-04-09T12:47:15Z","updated_on":"2014-04-09T12:47:15Z","custom_fields":[{"id":9,"name":"Billable","value":"1"}]},{"id":4975,"project":{"id":154,"name":"MyPrj"},"user":{"id":97,"name":"John Doe"},"activity":{"id":9,"name":"Development"},"hours":4.0,"comments":"Various studies","spent_on":"2014-04-07","created_on":"2014-04-07T16:06:40Z","updated_on":"2014-04-07T16:06:40Z","custom_fields":[{"id":9,"name":"Billable","value":"1"}]},{"id":4973,"project":{"id":154,"name":"MyPrj"},"issue":{"id":5334},"user":{"id":97,"name":"John Doe"},"activity":{"id":9,"name":"Development"},"hours":4.0,"comments":"Ended Scenario 2 and 3","spent_on":"2014-04-07","created_on":"2014-04-07T13:03:23Z","updated_on":"2014-04-07T13:03:23Z","custom_fields":[{"id":9,"name":"Billable","value":"1"}]},{"id":4971,"project":{"id":154,"name":"MyPrj"},"issue":{"id":5334},"user":{"id":90,"name":"John Doe"},"activity":{"id":9,"name":"Development"},"hours":8.0,"comments":"Task #5334: EE-10 - User Creation by PA","spent_on":"2014-04-04","created_on":"2014-04-07T12:10:33Z","updated_on":"2014-04-07T12:10:33Z","custom_fields":[{"id":9,"name":"Billable","value":"1"}]},{"id":4968,"project":{"id":33,"name":"Management"},"issue":{"id":5384},"user":{"id":13,"name":"John Doe"},"activity":{"id":40,"name":"Other"},"hours":1.0,"comments":"","spent_on":"2014-04-04","created_on":"2014-04-04T06:11:51Z","updated_on":"2014-04-04T06:11:51Z","custom_fields":[{"id":9,"name":"Billable","value":"1"}]},{"id":4970,"project":{"id":154,"name":"MyPrj"},"issue":{"id":5334},"user":{"id":90,"name":"John Doe"},"activity":{"id":9,"name":"Development"},"hours":8.0,"comments":"Task #5334: EE-10 - User Creation by PA","spent_on":"2014-04-03","created_on":"2014-04-07T12:09:08Z","updated_on":"2014-04-07T12:09:08Z","custom_fields":[{"id":9,"name":"Billable","value":"1"}]}],"total_count":2007,"offset":0,"limit":25}
==========
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.7/dist-packages/redmine/resources.py", line 227, in save
for item, value in self.manager.create(**self._changes):
File "/usr/local/lib/python2.7/dist-packages/redmine/managers.py", line 175, in create
resource = self.to_resource(response[self.container])
KeyError: 'time_entry'
>>>
As you can see I printed the id of the Time Entry so you can check if it's the one I updated, and also I used the date format (not datetime).
Thanks
from python-redmine.
Really strange, it seems to me that in your first case the create method is called instead of update that is why your comment update doesn't work. The second case I don't understand at all, it looks like the filter method is called instead of create which is nonsense. Again, I can't reproduce both of this cases here.
Can you reinstall the whole package and check that all the *.pyc files are deleted too.
If that still doesn't work, can you create a test account for me to debug this errors on your server if possible, you can send the account details to tepkeev at gmail dot com
from python-redmine.
Finally I found... it was my fault...
I searched in requests module for a bug, instead I found this in the comments:
Second, if a POST is responded to with a 301, turn it into a GET.
This bizarre behaviour is explained in Issue 1704.
I saw before the HTTP 301 return code, but I didn't give it too much importance but...
Then I realized that I was using "http" instead of "https"...
I tried using "https" and it worked like a charm.
Sorry if I wasted your time, thank you for the support.
from python-redmine.
Omg, what an unexpected behaviour.
Thanks for not giving up and investigating this. I wasn't aware of this. I believe I'll add a FAQ or something to the docs where I'll list such unexpected things to help other people.
from python-redmine.
Good idea!
I think it happens every time that a redirect take place.
from python-redmine.
Thanks for the hint, I jumped right into the same problem and was really puzzled by the keyerror exception.
from python-redmine.
Related Issues (20)
- tags from task HOT 2
- check the existence of a task HOT 1
- Copy project HOT 2
- Is it possible to integrate a "geojson" parameter in issue creation? HOT 2
- KeyError: 'time_entry' HOT 3
- Cant Set priority_id HOT 5
- When adding a user to a group that they are already a member of get "User is invalid" HOT 2
- How to: Create Issue onbehalf of another user HOT 4
- Bug: User does not return status HOT 3
- Bug: Users.all() does not return all users HOT 4
- When querying resources, why is there a default_includes HOT 2
- Leaks API key on exception HOT 2
- Filter by application subject HOT 2
- BytesIO is not JSON serializable HOT 4
- ResourceNotFoundError: Requested resource doesn't exist HOT 2
- Get Request - ResourceNotFoundError: Requested resource doesn't exist HOT 2
- filter error HOT 2
- ???????? for Russian text HOT 6
- adding custom fields to project HOT 2
- Get member users from project_membership HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from python-redmine.