-
Notifications
You must be signed in to change notification settings - Fork 120
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unable to save a new issue and custom fields ignored #10
Comments
As for the issue = redmine.issue.new()
issue.project_id = 'lsdt'
issue.subject = 'Test 1'
issue.save() I can confirm that this is a bug in Python Redmine and it will be fixed in the next release. Thanks for reporting this. As for the custom fields, you are using it incorrectly, there is example in the docs: issue = redmine.issue.create(
project_id='lsdt',
subject='Test 1',
custom_fields=[{'id': TESTFIELD_ID, 'value': TESTFIELD_VALUE}]
) I.e. you should use the id of the custom field and not a name to set it's value, exactly like in the example. |
Ah, I see. Thanks for the info. As a suggestion, begin able to pass in a simple dictionary for custom_fields as with custom_fields={'field': 'val'} in addition to a list as now would be a good enhancement and IMHO more Pythonic. Thanks! |
I'm using a list here because you might want to set several fields at once and not one. Of course I can add a check that if a dictionary is passed then we can assume that a single custom field should be set and we should wrap it in a list (Redmine requires a list even if a single custom field is set), but that will create inconsistency from the user point of view imho. Also, if I am not mistaken it is impossible to set a custom field via it's name, that's why I'm using an id here, but I'll check it to be sure, and if it's possible I will add such a functionality in Python Redmine. Anyway, thanks for the suggestion. |
Problem with the issue creation via new() method is fixed in f127314. It will be released to PyPI a little bit later, if you need a fix right now you can always install the latest development version from Github via pip. |
I've also checked custom fields, and as I expected, the only way to set them is via id. |
How do I find out what the ID is for a custom field? |
If you are using Redmine >= 2.4.0 you can issue an API request via For Redmine <= 2.4.0 you can go to You need to login with a user that has administrative privileges to get access to custom fields. |
I am using Python 2.7.5 with Requests 2.2.1 and Python-Redmine 0.6.0 running against a Redmine 2.3.0 server.
This works:
redmine = Redmine('http://redmine/', key='***')
issue = redmine.issue.create(project_id='lsdt', subject='Test 1')
This doesn't
issue = redmine.issue.new()
issue.project_id = 'lsdt'
issue.subject = 'Test 1'
issue.save()
which results in
redmine.exceptions.ResourceAttrError: Resource doesn't have the requested attribute
and no matter what I have tried with
issue = redmine.issue.create(project_id='lsdt', subject='Test 1', custom_fields=[{'TestField': 1}])
the field TestField is never populated. I have also tried using the update() method to update an existing one and it doesn't work.
The text was updated successfully, but these errors were encountered: