1

I am trying to open the folder and see the files inside

const children = await axios.get(
      `https://www.googleapis.com/drive/v3/files/${folder.id}`,
      {
        params: {
          fields: "files(id, name)",
          spaces: "drive",
        },
        headers: {
          authorization: `Bearer ${accessToken}`,
        },
      }
    );

can we open sub folder using folder id? i tried it but it show errors

2 Answers2

2

Check the q pram search opperators with file.list it will let you list the files with in a folder

q=parents%20in%20%27root%27

Or

curl \
  'https://www.googleapis.com/drive/v3/files?q=parents%20in%20%27root%27&key=[YOUR_API_KEY]' \
  --header 'Authorization: Bearer [YOUR_ACCESS_TOKEN]' \
  --header 'Accept: application/json' \
  --compressed
Linda Lawton - DaImTo
  • 106,405
  • 32
  • 180
  • 449
1

As google drive doc uses q parameter to get a list of files inside a folder

q:"'{FolderID}' in parents"

so your Axios get request will be like that

const emptyFoldersSearch2 = await axios.get(
      "https://www.googleapis.com/drive/v3/files",
      {
        params: {
          q:"'1VwXsYxTTGid9GIYHzkzD7LPFN5bRUSKD' in parents" ,
        },
        headers: {
          authorization: `Bearer ${accessToken}`,
        },
      }
    );
Syed Ali Shahzil
  • 1,079
  • 1
  • 11
  • 17