Search code examples
javascriptgoogle-drive-apimetadatagoogle-api-js-client

Google Drive API v3 doesn't list specified metadata of file/folder


Hello I'am in trouble trying to retrieve specified metadata fields with the Google Drive API v3 and javascript.

I use generic API request for that:

gapi.client.request({
          'path': 'https://www.googleapis.com/drive/v3/files/'+fileId,
          'fields': "files(id, name, size, parents)",
          'method': 'GET'
        })

but the response lists just

    "kind": "drive#file",
    "id": "0B99ZF.........Z",
    "name": "...",
    "mimeType": "..."

How can list the metadata specified in the request:

'fields': 'files(id, name, size, parents)'

Thank you for the reply.


Solution

  • You have constructed the parameter object to gapi.client.request incorrectly. Try...

    gapi.client.request({
              'path': 'https://www.googleapis.com/drive/v3/files/'+fileId,
              'params' : {'fields': "*"},
              'method': 'GET' 
            })
    

    or simply add &fields=* to your URL. See https://developers.google.com/api-client-library/javascript/reference/referencedocs#gapiclientrequest