Redmine问题创建代码
我目前正在编写一个插件,通过 http post 请求创建一个新问题。我目前在创建和保存新问题时遇到问题。每次我调用 Issue.save 时,它都会返回 false。我希望有人能指出我正确的方向。预先感谢您
这是我目前拥有的代码:
issue = Issue.new
issue.tracker = Tracker.find_by_name("Bug")
issue.subject = params[:subject]
issue.description = params[:description]
issue.project = Project.find_by_name(params[:project])
issue.start_date = Time.now.localtime.strftime("%Y-%m-%d")
issue.priority = IssuePriority.find_by_name("Normal")
issue.author = User.find_by_mail("[email protected]")
issue.status = IssueStatus.find_by_name("New")
issue.save
I am currently writing a plugin the creates a new issue via a http post request. I am currently Having issues with creating and saving a new issue. Every time I cal issue.save, it returns false. I was hoping that someone would point me in the right direction. Thank you in advance
Here is the code I currently have:
issue = Issue.new
issue.tracker = Tracker.find_by_name("Bug")
issue.subject = params[:subject]
issue.description = params[:description]
issue.project = Project.find_by_name(params[:project])
issue.start_date = Time.now.localtime.strftime("%Y-%m-%d")
issue.priority = IssuePriority.find_by_name("Normal")
issue.author = User.find_by_mail("[email protected]")
issue.status = IssueStatus.find_by_name("New")
issue.save
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
出现一些错误!检查 issues.errors 以检查以下内容:
Some error occurs! Examine issue.errors to check which:
您可以使用 REST API 在 Redmine 中创建问题(以及执行许多其他操作)。
You can create Issues (and do many other things) in Redmine using REST API.
感谢您的快速回复,他们对我帮助很大。
调用
issue.errors.full_messages
后,我发现无法保存问题,因为未设置所需的自定义字段。我在调用 issues.save 之前添加了以下代码,
这里也是我的 create_custom_value 方法
Thank you for all your quick responses, They have helped me significantly.
After calling
issue.errors.full_messages
, I discovered that I could not save the issue because required custom fields were not set.I added the following code before calling issue.save
also here is my create_custom_value method