title: How to properly format json to send over using RestClient
body: <p>I am trying to implement this javascript code </p>
  
  <pre><code>var token = "&lt;page_access_token&gt;";
  
  function sendTextMessage(sender, text) {
    messageData = {
      text:text
    }
    request({
      url: 'https://graph.facebook.com/v2.6/me/messages',
      qs: {access_token:token},
      method: 'POST',
      json: {
        recipient: {id:sender},
        message: messageData,
      }
    }, function(error, response, body) {
      if (error) {
        console.log('Error sending message: ', error);
      } else if (response.body.error) {
        console.log('Error: ', response.body.error);
      }
    });
  }
  </code></pre>
  
  <p>into ruby on rails code</p>
  
  <pre><code>def reply_back(sender, text)
        page_token = "*****"
  
        base_uri = "https://graph.facebook.com/v2.6/me/messages"
  
        messageData = {
          text: text
        }
  
        qs = {
          access_token: page_token
        }
  
        json = {
          recipient: {
            id: sender
          },
          message: messageData
        }
  
        response = RestClient.post base_uri, qs.to_json, json.to_json, :content_type =&gt; :json, :accept =&gt; :json
        p "this is the response #{response}"
  
      end
  </code></pre>
  
  <p>but obviously i am doing something wrong, i am getting this in console</p>
  
  <p><code>(wrong number of arguments (4 for 2..3))</code></p>
  
  <p>on line</p>
  
  <p><code>response = RestClient.post base_uri, qs.to_json, json.to_json, :content_type =&gt; :json, :accept =&gt; :json</code></p>
  
  <p>any insight?</p>