title: Connect API to Sheets using Python
body: <p>I have managed to read from the sheets separately and I have managed to write to them, on the other hand I have access to the API, I'm just trying to put it all together and by the way learn Python, could someone help me?</p>
  <p>I can't get the API response to be written in the sheet, it doesn't give me any error, it only tells me that it has connected but that it hasn't updated any column or any cell</p>
  <pre><code>from __future__ import print_function
  
  import os.path
  
  from google.auth.transport.requests import Request
  from google.oauth2.credentials import Credentials
  from google_auth_oauthlib.flow import InstalledAppFlow
  from googleapiclient.discovery import build
  from googleapiclient.errors import HttpError
  from google.oauth2 import service_account
  import requests
  import json
  
  #-------------------------------------------------------------------
  
  def temilla ():
  
    BASE_URL = &quot;https://company.com&quot;
  
    token = 'RYE_'
  
    #headers = {'Content-Type':'application/x-www-form-urlencoded','Authorization': &quot;Bearer {}&quot;.format(token)}
    PARAMS = {&quot;employee_ids&quot;:&quot;1007&quot;,
             #&quot;employee_ids&quot;:&quot;1388&quot;,
             #&quot;business_unit_ids&quot;:&quot;13&quot;,
             &quot;start_date&quot;:&quot;08/07/2022&quot;,
             &quot;end_date&quot;:&quot;09/07/2022&quot;
             }
    headers = {&quot;Content-Type&quot;: &quot;application/json&quot;,'Authorization': &quot;Bearer {}&quot;.format(token), &quot;Api-version&quot;: &quot;1.0&quot;}
    response = requests.get(BASE_URL, params = PARAMS, headers = headers )
  
    result = [response.content]
  
    print(response.content)
  
    #--------------------------------------------------------------------------
  
   SERVICE_ACCOUNT_FILE = 'keys.json'
   SCOPES = ['https://www.googleapis.com/auth/spreadsheets']
  
  creds = None
  creds = service_account.Credentials.from_service_account_file(
          SERVICE_ACCOUNT_FILE, scopes=SCOPES)
  
    #--------------------------------------------------------------------------
  
  SCOPES = ['https://www.googleapis.com/auth/spreadsheets.readonly']
  
  SAMPLE_SPREADSHEET_ID = '146456464646464'
  
  service = build('sheets', 'v4', credentials=creds)
  
  sheet = service.spreadsheets()
  result = sheet.values().get(spreadsheetId=SAMPLE_SPREADSHEET_ID,
                           range=&quot;Horarios!A1:J20&quot;).execute()
  
  print(result)
  
  values = result.get('values', [])
  
  temilla()
  
  Cosilla = temilla()
  #Cosilla = [[&quot;DIA&quot;,1],[&quot;AÑO&quot;,2022],[&quot;MES&quot;,9],[&quot;EMPLEADO&quot;,&quot;MARIANO&quot;],[&quot;ACTIVO&quot;,True]]
  
  request = sheet.values().update(spreadsheetId=SAMPLE_SPREADSHEET_ID,
                      range=&quot;Prueba-Escritura!a1:xa&quot;, valueInputOption=&quot;USER_ENTERED&quot;, body= 
  {&quot;values&quot;:Cosilla}).execute()
  
  #print(result)
  #print(values)
  print(request)
  </code></pre>
  <p>The response that the API gives me is similar to the following</p>
  <p>b'[{&quot;shift_id&quot;:2400298,&quot;business_unit_id&quot;:10,&quot;business_unit&quot;:&quot;alguno&quot;,&quot;employee_id&quot;:1007,&quot;employee_code&quot;:&quot;11111111&quot;,&quot;entry&quot;:&quot;2022-08-07T11:30:00&quot;,&quot;exit&quot;:&quot;2022-08-07T15:30:00&quot;},{&quot;shift_id&quot;:2400299,&quot;business_unit_id&quot;:10,&quot;business_unit&quot;:&quot;alguno&quot;,&quot;employee_id&quot;:1007,&quot;employee_code&quot;:&quot;1111111&quot;,&quot;entry&quot;:&quot;2022-08-07T19:00:00&quot;,&quot;exit&quot;:&quot;2022-08-07T23:00:00&quot;}]'</p>