title: Google Sheets v4 API Ruby - Trying to update values in cells in a column but the updates are not happening
body: <p><strong>Ruby: 2.3.1</strong></p>
  
  <p><strong>Rails: 5.0.0</strong></p>
  
  <p>I have a sheet containing data like below: A, B , C, D represents the columns name in the sheet and 1, 2, 3 represents the row numbers.</p>
  
  <p><a href="https://i.stack.imgur.com/8gQDj.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/8gQDj.png" alt="enter image description here"></a></p>
  
  <p>I have written a script mentioned about <a href="https://stackoverflow.com/q/39216040/936494">here</a> and from it I am trying to update the values in cells <strong>B2</strong> and <strong>B3</strong> and for updating I am using the following code:</p>
  
  <pre><code>spreadsheet_id = "&lt;My Private Spreadsheet ID&gt;"
  
  range = 'Sheet1!B2:B3'
  
  value_range_object = { 
    "majorDimension"=&gt;"COLUMNS", 
    "values"=&gt;[
       [9, 18] # B2 should be updated with value 9 and B3 should be updated with value 18
     ]
  }
  
  service = Google::Apis::SheetsV4::SheetsService.new
  service.authorization = authorization
  update_res = service.update_spreadsheet_value(spreadsheet_id, range, value_range_object, value_input_option: 'USER_ENTERED')
  
  puts "&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; update_res: #{update_res.inspect}"
  </code></pre>
  
  <p>But that puts is printing </p>
  
  <pre><code>&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; update_res: #&lt;Google::Apis::SheetsV4::UpdateValuesResponse:0x000000068acc70 @updated_range="Sheet1!B2", @spreadsheet_id="&lt;My Private Spreadsheet ID&gt;"&gt;
  </code></pre>
  
  <p>and there are no updates made to the sheet.</p>
  
  <p>As per the <a href="https://developers.google.com/sheets/samples/writing" rel="nofollow noreferrer">documentation</a> when an update is successful following kind of response should be received</p>
  
  <pre><code>{
    "spreadsheetId": spreadsheetId,
    "updatedRange": "Sheet1!B1:D5",
    "updatedRows": 3,
    "updatedColumns": 2,
    "updatedCells": 6,
  }
  </code></pre>
  
  <p>Comparing that with the response I am getting there is definitely something which is missing or incorrect in my code and which is hampering the updates to be applied.</p>
  
  <p>Can I please get some guidance to get past my problem and hence achieve my desired goal? </p>
  
  <p><strong>Update</strong></p>
  
  <p>I tried out this with a slightly different approach following the example given at <a href="https://developers.google.com/sheets/samples/writing#write_a_single_range" rel="nofollow noreferrer">https://developers.google.com/sheets/samples/writing#write_a_single_range</a></p>
  
  <p>As part of this I created a fresh new blank sheet on Google Drive, shared it with my Service Account and tried to update it with the following code:</p>
  
  <pre><code>require 'google/apis/sheets_v4'
  
  ENV["GOOGLE_ACCOUNT_TYPE"] = 'service_account'
  ENV["GOOGLE_CLIENT_EMAIL"] = '&lt;client_email_from_downloaded_json_here&gt;'
  ENV["GOOGLE_PRIVATE_KEY"] = "&lt;private_key_from_downloaded_json_here&gt;"
  
  SCOPE = Google::Apis::SheetsV4::AUTH_SPREADSHEETS
  
  authorization = Google::Auth.get_application_default(SCOPE)
  
  # Initialize the API
  service = Google::Apis::SheetsV4::SheetsService.new
  service.authorization = authorization
  
  spreadsheet_id = '&lt;MY SPREADSHEET ID HERE&gt;'
  
  sheet_name = 'Sheet1'
  
  range = "Sheet1!A1:D5"
  
  value_range_object = {
    "majorDimension" =&gt; "ROWS",
    "values" =&gt; [
       ["Item", "Cost", "Stocked", "Ship Date"],
       ["Wheel", "$20.50", "4", "3/1/2016"],
       ["Door", "$15", "2", "3/15/2016"],
       ["Engine", "$100", "1", "30/20/2016"],
       ["Totals", "=SUM(B2:B4)", "=SUM(C2:C4)", "=MAX(D2:D4)"]
     ]
  }
  
  
  update_res = service.update_spreadsheet_value(spreadsheet_id, range, value_range_object, value_input_option: 'USER_ENTERED')
  
  puts "&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; update_res: #{update_res.inspect}"
  </code></pre>
  
  <p>But strangely that is also not working. I am getting the following response</p>
  
  <pre><code>&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; update_res: #&lt;Google::Apis::SheetsV4::UpdateValuesResponse:0x00000006540348 @updated_range="Sheet1!A1", @spreadsheet_id="MY SPREADSHEET ID HERE"&gt;
  </code></pre>
  
  <p>and the sheet is also blank after executing the code.</p>
  
  <p>Can anybody please take a look into this and comment on what is going on?</p>