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

190
Vistas
Google Drive api Error gapi.client.request

Hello guys I am using Google Picker API but when i comes to this code

var request1 =  gapi.client.request({
                        'path': '/drive/v3/files/' + fileID + '/permissions',
                        'method': 'POST',
                        'headers': {
                            'Content-Type': 'application/json',
                            'Authorization': 'Bearer ' + oauthToken
                        },
                        'body': {
                            'role': role,
                            'type': type
                        }
                    });
                    request1.execute(function (resp) {
                        console.log(resp);
                    });

I keep on getting error on gapi.client.request, you see in the image below. I don't what Im doing wrong here I also search alot in the google. And this code is also same with the code that I found in google and I need this to run in my website but I keep getting this error.

Any idea will do thank you. Uncaught TypeError: Cannot read properties of undefined (reading 'request')

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

0

Loading the library takes a bit of time to complete before it is fully loaded. So when you try to use gapi.client.request, gapi.client is still undefined.

Make sure the library is loaded before proceeding.

Sample:

<body>
  Tester2
  <script>
    googleApiClientReady = function () {
      var request1 =  gapi.client.request({
        'path': '/drive/v3/files/' + fileID + '/permissions',
        'method': 'POST',
        'headers': {
          'Content-Type': 'application/json',           
          'Authorization': 'Bearer ' + oauthToken
        },
        'body': {
          'role': role,
          'type': type
        }
      });
      request1.execute(function (resp) {
        console.log(resp);
      });
    }
  </script>
  <script src="https://apis.google.com/js/client.js?onload=googleApiClientReady"></script>
</body>

Output:

output

Error now proceeds to undefined fileID instead of undefined gapi.client, inferring that the latter is now defined.

Note:

  • If you want to update a file in drive, method should be PATCH not POST. (reference: PATCH vs POST)
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