Search code examples
rubyrest-clientslack-api

Getting 500 error when using Slack's incoming Webhook via a Ruby rest_client


I use the following to post to Slack's incoming Webhook:

slack_incoming_webhook = 'URL....."
payload={
        "text"=> bot_response[:bot_response],
         "channel"=>"@mememem"
    }

jsonresponse = RestClient.post slack_incoming_webhook, payload, :content_type => 'application/json'

I get the following error:

RestClient::InternalServerError: 500 Internal Server Error

The post appears to be posting correctly when I check it on request_bin, so I am unclear how to resolve this error.


Solution

  • Try

    require 'json'
    payload={   
            "text"=> bot_response[:bot_response],
             "channel"=>"@mememem"
        }.to_json