Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Send card doesnt work #189

Open
pchaganti opened this issue Jan 17, 2017 · 2 comments
Open

Send card doesnt work #189

pchaganti opened this issue Jan 17, 2017 · 2 comments

Comments

@pchaganti
Copy link

Unable to get this to work. The error message is rather cryptic about what is missing. Anyone have any pointers?

client = HipChat::Client.new(api_token, :api_version => 'v2')

card = {
    :style => 'application',
    :title => 'My Awesome Card',
    :id => 12345 ,
    :format => "html"
}

client[roomid].send('Tester', 'Testing Card', :color => 'red', :card => card)
The request was invalid. You may be missing a required argument or provided bad data. 
path:/my-card-test/notification method:Net::HTTP::Post (HipChat::BadRequest)
@dodontommy
Copy link

+1 getting the same thing

@joshuamcginnis
Copy link

joshuamcginnis commented Feb 20, 2018

@pchaganti @tommybstitch

This works for me.

require 'hipchat'
require 'securerandom'

client = HipChat::Client.new(my_token)

card = {
  style: 'application',
  title: 'Example Title',
  id: SecureRandom.uuid,
  url: 'my_url',
  description: {
    format: :html,
    value: 'This is a test'
  },
  attributes: [
    {
      label: 'Total Records',
      value: { label: '1082404', style: 'lozenge-success' }
    },
    {
      label: 'Total Runtime',
      value: { label: '0.39 seconds', style: 'lozenge' }
    },
  ]
}

room = client['Test']

room.send('test_sender', 'test_message', message_format: :html, card: card)

This list of required fields are here:
https://www.hipchat.com/docs/apiv2/method/send_room_notification

Example API payloads are here:
https://developer.atlassian.com/server/hipchat/messages/

Hope this helps!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants