title: Fusion Tables: Why do I keep getting a "400 Bad Request" error when trying to update a table style via Ruby's RestClient gem
body: <p>I'm trying to update a style for one of my Fusion Tables by using the Ruby gem RestClient.</p>
  
  <p>Here's my code:</p>
  
  <pre><code>require 'rest_client'
  
  tableId = '&lt;STRING CONTAINING TABLEID&gt;'
  styleId = '&lt;STRING CONTAINING STYLEID&gt;'
  key = '&lt;STRING CONTAINING MY FUSION TABLES API KEY&gt;'
  
  table_url = "https://www.googleapis.com/fusiontables/v1/tables/#{tableId}/styles/#{styleId}?key=#{key}"
  update = '{"polygonOptions": {"strokeColor":"#ffffff"}}'
  
  token = 'STRING CONTAINING AUTHORIZATION TOKEN'
  
  RestClient.put table_url,update,{"Authorization" =&gt; "Bearer #{token}"}
  </code></pre>
  
  <p>When I run that code, I get this error:</p>
  
  <pre><code>C:/Ruby193/lib/ruby/gems/1.9.1/gems/rest-client-1.6.7/lib/restclient/abstract_response.rb:48:in `return!': 400 Bad Request (RestClient::BadRequest)
      from C:/Ruby193/lib/ruby/gems/1.9.1/gems/rest-client-1.6.7/lib/restclient/request.rb:230:in `process_result'
      from C:/Ruby193/lib/ruby/gems/1.9.1/gems/rest-client-1.6.7/lib/restclient/request.rb:178:in `block in transmit'
      from C:/Ruby193/lib/ruby/1.9.1/net/http.rb:745:in `start'
      from C:/Ruby193/lib/ruby/gems/1.9.1/gems/rest-client-1.6.7/lib/restclient/request.rb:172:in `transmit'
      from C:/Ruby193/lib/ruby/gems/1.9.1/gems/rest-client-1.6.7/lib/restclient/request.rb:64:in `execute'
      from C:/Ruby193/lib/ruby/gems/1.9.1/gems/rest-client-1.6.7/lib/restclient/request.rb:33:in `execute'
      from C:/Ruby193/lib/ruby/gems/1.9.1/gems/rest-client-1.6.7/lib/restclient.rb:80:in `put'
  </code></pre>
  
  <p>When I input the <code>update</code> code into <a href="https://developers.google.com/fusiontables/docs/v1/reference/style/update" rel="nofollow">Google's official Style request PUT maker thingie</a>, the update works. But it does not work when I run my Ruby code.</p>
  
  <p>Does anyone know what I am doing wrong?</p>
  
  <p>EDIT: Extra output I get from adding in <code>RestClient.log = logger</code></p>
  
  <pre><code>RestClient.put "https://www.googleapis.com/fusiontables/v1/tables/&lt;MY TABLE ID HERE&gt;/styles/4?key=&lt;AND HERE'S WHERE MY FUSION TABLE API KEY GOES&gt;", "{\"polygonOptions\":{\"strokeColor\":\"#ffffff\"}}", "Accept"=&gt;"*/*; q=0.5, application/xml", "Accept-Encoding"=&gt;"gzip, deflate", "Authorization"=&gt;"Bearer &lt;THIS CONTAINS THE BEARER STRING&gt;", "Content-Length"=&gt;"44"
  # =&gt; 400 BadRequest | application/json 255 bytes
  </code></pre>