Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

155
Vistas
modify google spreadsheet using Ajax javascript only

i am using javascript only to read and write values in google spreadsheet (private sheet using oAuth). I can successfully read the values but i am getting issue on modifying the sheet. below is my code for updating the cell-

$.ajax({ type: 'post', headers: { Authorization: auth, 'content-type': 'application/json', "access_token": auth, }, data: JSON.stringify({ // generate from oAuthPlayground "access_token": auth,

                "range": "A1",
                "values": [
                    [
                        "32",
                        
                    ]
                ]
            
            
            }),              
            url: 'https://sheets.googleapis.com/v4/spreadsheets/' + sheetId + '/values/A2:batchUpdate?insertDataOption=INSERT_ROWS&valueInputOption=RAW',               
            success: function (r) {
                console.log(r)
            }, error: function (r) {
                console.log(r)
            }
        });

anybody can suggest what is the mistake. Again i am using only ajax not node.js or google script.

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

From your showing script, I couldn't understand the following.

  • What method in Sheets API do you want to use?
  • Which do you want to put the value to the cell "A1" or "A2".
  • I couldn't understand whether your access token can be used for updating the Spreadsheet.

From this situation, I guessed your current issue and your goal as follows.

  • You want to put a value of "32" to a cell "A1" of the 1st sheet of the Spreadsheet.
    • In this case, "Method: spreadsheets.values.update" is used.
  • Your access token can be used for updating the Spreadsheet.

In this case, how about the following sample script?

Sample script:

const auth = "Bearer ###"; // Please replace "###" with your access token.
const sheetId = "###"; // Please set your Spreadsheet ID.

$.ajax({
  type: 'put',
  headers: { Authorization: auth, 'content-type': 'application/json' },
  data: JSON.stringify({
    "values": [["32"]]
  }),
  url: 'https://sheets.googleapis.com/v4/spreadsheets/' + sheetId + '/values/A1?valueInputOption=RAW',
  success: function (r) {
    console.log(r)
  }, error: function (r) {
    console.log(r)
  }
});
  • When this script is run, "32" is put to a cell "A1" of the 1st sheet of the Spreadsheet.

Reference:

  • Method: spreadsheets.values.update
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda