I am trying to find the syntax for inserting a new Relation between issues in Redmine using Ruby.
The code I've been trying:
require 'rubygems'
require 'active_resource'
class Issue < ActiveResource::Base
self.site = '[the site]'
self.user = '[the user]'
self.password = '[the password]' #not hard coded
self.format = :json #I've had issues with Issue.find(i) without explicitly stating the format
end
class IssueRelation < ActiveResource::Base
self.site = '[the site]'
self.user = '[the user]'
self.password = '[the password]' #not hard coded
self.format = :json #I've had issues with Issue.find(i) without explicitly stating the format
end
issue1 = Issue.find(1)
issue2 = Issue.find(2)
puts issue1.id
puts issue2.id
relation = IssueRelation.new(
:issue => issue1,
:issue_to => issue2,
:relation_type => 'relates'
)
if relation.save
puts relation.id
else
puts relation.errors.full_message
end
The output I get back:
1
2
...'handle_response': Failed. Response code = 404. Response Message = not found.
The output suggests that Issue 1 and 2 were successfully found, but that the name I'm using for the relation is not valid, hence the 404 not found.
What is the correct syntax for creating a relation in Redmine's API given that I have found the two issues that it will link?