restgoogle-drive-apigoogle-drive-android-apioauth2-playground

How to get data of specific file ID in Google REST query?


I was experimenting the GoogleDrive-v3 REST apis in OAuth2 playground. In that I was trying to filter the field for the specific file info from the response with the file ID/filename.

{
    "mimeType": "image/png", 
    "kind": "drive#file", 
    "id": "PuwuUXGsjLaf6gxyrye_g7OmMw", 
    "name": "google.png"
}

Here, I pasted my REST query to filter the file info with the file ID "PuwuUXGsjLaf6gxyrye_g7OmMw". But, it doesn't filter the response for the specified file ID. Instead it print complete response of the REST query.

https://www.googleapis.com/drive/v3/files?fields=files&id=PuwuUXGsjLaf6gxyrye_g7OmMw

Correct me what I am missing here. Thanks in Advance.


Solution

  • The query parameter "q" can be used to retrieve the file info with the file ID or with the filename.

    Here, I retrieved the file "ubuntu_logo.png" with the filename from my google drive.

    For Example:

    https://www.googleapis.com/drive/v3/files?q=name='ubuntu_logo.png'
    

    Response:

    {
      "incompleteSearch": false, 
      "files": [
        {
          "mimeType": "image/png", 
          "kind": "drive#file", 
          "id": "11n2avML9mfI3IzS57qxV7aT1_uLxM8Wv", 
          "name": "ubuntu_logo.png"
        }
      ], 
      "kind": "drive#fileList"
    }