title: curl post request in rails controller
body: <p>I want to convert this post request written in curl (GoPay payment gateway) to my Rails application:</p>
  
  <pre><code>curl -v https://gw.sandbox.gopay.com/api/oauth2/token \
  -X "POST" \
  -H "Accept: application/json" \
  -H "Content-Type: application/x-www-form-urlencoded" \
  -u "&lt;Client ID&gt;:&lt;Client Secret&gt;" \
  -d "grant_type=client_credentials&amp;scope=payment-create"
  </code></pre>
  
  <p>I am trying to do in my rails controller by using a gem <strong>rest-client</strong>. I've done something like this and was modifiying many times but couldn't make it works:</p>
  
  <pre><code>RestClient::Request.execute( method: :post, 
                               url: "https://gw.sandbox.gopay.com/api/oauth2/token",
                               "#{ENV['GOPAY_CLIENT_ID']}": "#{ENV['GOPAY_CLIENT_SECRET']}"
                               data: "grant_type=client_credentials&amp;scope=payment-create" 
                               )
  </code></pre>
  
  <p>How I can convert the curl post request for the rest-client (or similar)?</p>
  
  <p>EDIT: It is showing a status code 409: Conflict with no further information</p>
  
  <p>EDIT1 - rgo's modified code works, thank you: </p>
  
  <pre><code>RestClient.post "https://#{ENV['GOPAY_CLIENT_ID']}:#{ENV['GOPAY_CLIENT_SECRET']}@gw.sandbox.gopay.com/api/oauth2/token", 
      { grant_type: 'client_credentials', scope: 'payment-create'}, 
      content_type: :json, accept: :json
  </code></pre>