Jaffa
Jaffa

Reputation: 12719

Trying to create issue on redmine from rails app

We have a redmine server and a web application written in RoR. I'm trying to create issues from my website with the following ActiveResource object:

module Redmine
  class Issue < ActiveResource::Base
    self.site = "http..."
    headers["X-Redmine-API-Key"] = "..."
  end
end

The server is not publicly accessible, so my API key is working well as I can get any issue doing Redmine::Issue.find(1)

When I try to create a new issue with the following code, it always fails:

Redmine::Issue.create({
  subject: "Hello, World",
  project_id: 3
})

With the error message "Sujet doit être renseigné(e)", which means "Subject can't be blank".

The subject is the first parameter I give to the issue, so I really don't understand where can this come from!

I'm following the Redmine wiki.

Edit: I'm using my personal API key for the moment, so I'm administrator on the redmine

Upvotes: 2

Views: 1038

Answers (2)

Noma4i
Noma4i

Reputation: 770

Try https://rubygems.org/gems/redmine_client with that gem you will be able to create issues like:

  RedmineClient::Issue.create(
    :subject => "My Subject",
    :project_id => PROPER_PROJECT_ID,
    :status_id => PROPER_STATUS_ID,
    :description => "description goes here",
    :tracker_id => PROPER_TRACKER_ID,
    :priority_id => PROPER_PRIORITY_ID
  )

Upvotes: 0

Jaffa
Jaffa

Reputation: 12719

Actually the problem comes from ActiveResource configuration, I have to manually add include_root_in_json = true in my object for the method to work.

I don't know if this is a normal behavior, but I'll comment it on redmine wiki also.

Upvotes: 2

Related Questions