Skip to content
Advertisement

Getting WebViewLinks with Google Drive

I’ve just started trying to use the Google Drive API. Using the quickstart guide I set up the authentication, I can print a list of my files and I can even make copies. All that works great, however I’m having trouble trying to access data from a file on Drive. In particular, I’m trying to get a WebViewLink, however when I call .get I receive only a small dictionary that has barely any of the file’s metadata. The documentation makes it look like all the data should just be there by default but it’s not appearing. I couldn’t find any way to flag for requesting any additional information.

JavaScript

This is the output of the above code: (the formatting is my doing)

JavaScript

For anyone confused about the code there is some missing that’s just the basic get_credentials function from the API’s quickstart page and some constants and imports. For completeness, here’s all that stuff, unmodified in my code:

JavaScript

So what’s missing, how can I get the API to return all that extra meta data that’s just not appearing right now?

Advertisement

Answer

You are very close. With the newer version of the Drive API v3, to retrieve other metadata properties, you will have to add the fields parameter to specify additional properties to include in a partial response.

In your case, since you are looking to retrieve the WebViewLinkproperty your request should look something similar to this:

JavaScript

To display your items from the response:

JavaScript

I also suggest try it out with the API Explorer so you can view what additional metadata properties you would like to display on your response.

Good Luck and Hope this helps ! :)

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement