Mark Embling
Mark Embling

Reputation: 12831

Getting additional fields in list operation for Google Drives API v3

I'm attempting to use the Google Drive API v3 to list out all the shared drives which the user has access to, along with some additional fields.

I've determined that I can use the fields optional parameter to list the fields I want, but am running into the situation where it does not seem to want to give me what I ask for.

The fields I'm specifically after are:

All these examples below have been tried in the Google API explorer.

With no fields specified, I get the following. This is expected.

{
 "kind": "drive#driveList",
 "nextPageToken": "...",
 "drives": [
  {
   "kind": "drive#drive",
   "id": "xxxx",
   "name": "Example Drive"
  },
  {
   "kind": "drive#drive",
   "id": "xxxy",
   "name": "Another Example Drive"
  },
  // ...

With a fields value of drives(id,name,capabilities), I get:

{
 "drives": [
  {
   "id": "xxxx",
   "name": "Example Drive"
  },
  {
   "id": "xxxy",
   "name": "Another Example Drive"
  },
  // ...

As you can see, the fields I don't need have been removed, but the fields I wanted to opt into have not be added. I wondered if I had just got something wrong in regards to the fact that capabilities is itself an object, but trying it with another simple property (hidden) also yields no luck.

What else do I need to do to make this work?

Upvotes: 0

Views: 166

Answers (2)

ZektorH
ZektorH

Reputation: 2770

The Google Drive API v3 does not support this.

However, the Google Drive API v2 does! You can try it out here.

If you are not able to use v2 instead of v3, you will have to do what @DalmTo suggested and fetch all the IDs of the drives, then get each one to retrieve the fields you want.

Hope this helps!

Upvotes: 0

Linda Lawton - DaImTo
Linda Lawton - DaImTo

Reputation: 117166

Fields * should return all of the fields available for any response

GET https://www.googleapis.com/drive/v3/drives?fields=*&key={YOUR_API_KEY}

I cant test this i dont have access to any shared drives.

{
 "kind": "drive#driveList",
 "drives": [
 ]
}

If you try doing a drive get on each drive again with fields=* you may get some additional information about the drive that way.

https://developers.google.com/drive/api/v3/reference/drives/get

Upvotes: 1

Related Questions