messagebird/ruby-rest-api

Issue with send_conversation_message

emorissettegregoire opened this issue · 2 comments

Hi folks,
For versions > 1.4.2 when calling the send_conversation_message method

channel_id = "my_channel_id"
to = "my_whatsapp_number"
client = MessageBird::Client.new('MY_ACCESS_KEY')
message = client.send_conversation_message(channel_id, to, type: 'text', content: { text: 'Hello!' })

I receive the following error:

MessageBird::ErrorException: MessageBird::ErrorException
.../gems/ruby-2.7.4/gems/messagebird-rest-3.1.1/lib/messagebird/client.rb:91:in `parse_body' when calling this method.

It is working properly for version <= 1.4.2

Thank you for helping.

qvrb commented

that error is fixed in 4.0.0 but there's an issue in 4.0.0 with respect to channel_id being passed instead of ChannelId

qvrb commented

if you're stuck on 3.0.0 the issue is that the call expects a hash params.merge but then it calls JSON.parse in the parse_body method which expects a string. So the answer is to override the parse_body

    def parse_body(body)
      json = body.class == String ? body : body.to_json
      super(json)
    end