0

So this is related to an earlier post I made on this method. This is essentially what I am using to send files via hipchat:

#!/usr/bin/env ruby
require 'hipchat'

client = HipChat::Client.new('HIPCHAT_TOKEN', :api_version => 'v2', :server_url => 'HIPCHAT_URL')
client.user('some_username').send_file('message', File.open('./output/some-file.csv') )
client['some_hipchat_room'].send_file('some_user', 'message', File.open('./output/some-file.csv') ) 

Now for some reason the send_file method is invalid:

/path/to/gems/hipchat-1.5.4/lib/hipchat/errors.rb:40:in `response_code_to_exception_for': You requested an invalid method. path:https://hipchat.illum.io/v2/user/myuser@myemail/share/file?auth_token=asdfgibberishasdf method:Net::HTTP::Get (HipChat::MethodNotAllowed)
    from /path/to/gems/gems/hipchat-1.5.4/lib/hipchat/user.rb:50:in `send_file'
Alex Cohen
  • 5,596
  • 16
  • 54
  • 104

2 Answers2

0

I think this indicating that you should be using POST instead of GET, but I'm not sure because I haven't used this library nor Hipchat.

Looking at the question you referenced and the source posted by another user they're sending the request using self.class.post, and your debug output shows Net::HTTP::Get

To debug, could you try,

file = Tempfile.new('foo').tap do |f|
  f.write("the content")
  f.rewind
end

user = client.user(some_username)
user.send_file('some bytes', file)
Josh Brody
  • 5,153
  • 1
  • 14
  • 25
0

The issue is that I was attempting to connect to the server via http instead of https. If the following client is causing issues:

client = HipChat::Client.new('HIPCHAT_TOKEN', :api_version => 'v2', :server_url => 'my.company.com')

Then try adding https:// to the beginning of your company's name.

client = HipChat::Client.new('HIPCHAT_TOKEN', :api_version => 'v2', :server_url => 'https://my.company.com')
Alex Cohen
  • 5,596
  • 16
  • 54
  • 104