0

I am sending attachments from Redmine to JIRA. This is the code I'm using for it:

if attachments.present?
  begin
  curl = SynchCurl.get_jira_curl_instance "jira_url"
  curl.multipart_form_post = true
  curl.headers["X-Atlassian-Token"] = "no-check"
  attachments.each do |sa|
    curl.http_post(Curl::PostField.file('file', sa.disk_filename, remote_file_name = sa.filename))
  end
  rescue Exception => e
  CommonSynch.manage_jira_errors e
  end
end

Now I want to check if the attachments are being saved on JIRA via Easy Callbacks to show the user an error message. I tried with:

curl.on_failure {|easy| puts "Error message"}

And some modifications under the post request, but the callback is always getting a nil value (I modified my code to provoke a 500 response code).

How can I do this?

Sorry if this is a dumb question, im pretty new in RoR. Thanks in advance.

  • side advice: don't rescue from Exception , http://stackoverflow.com/questions/10048173/why-is-it-bad-style-to-rescue-exception-e-in-ruby – niceman Jun 16 '16 at 19:39
  • can you post the code of `get_jira_curl_instance` ? – niceman Jun 16 '16 at 19:43
  • Not now niceman, Im at home. Anyways, get_jira_curl_instance just returns an url object with user/pass credentials (a preconf JIRA user) which its allowed to add the attachments in JIRA. –  Jun 16 '16 at 20:56

0 Answers0