How to properly format json to send over using RestClient
You should put all your params in one params hash like this:
params = { recipient: { id: sender }, message: { text: text }, access_token: page_token } response = RestClient.post base_uri, params.to_json, content_type: 'application/json', accept: 'application/json' p "this is the response #{response}"
According to documentation, you should merge you params and pass it in method as one object:
params = qs.merge(json)response = RestClient.post(base_uri, params.to_json, content_type: :json, accept: :json)
This method expects 2 or 3 arguments. In this case the third argument is a hash { content_type: :json, accept: :json }. Since it is a last argument, you can omit curly braces.