Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Google Drive V3 FileListCall Missing Data #501

Open
cloud303-cholden opened this issue May 29, 2024 · 2 comments
Open

Google Drive V3 FileListCall Missing Data #501

cloud303-cholden opened this issue May 29, 2024 · 2 comments

Comments

@cloud303-cholden
Copy link

When I do a file list request like below, most of the return values are None. This didn't seem right, so I tried doing the request manually, and this returned data. Hope this helps!

Bad code
let resp = hub
    .files()
    .list()
    .add_scopes(scopes)
    .corpora("drive")
    .drive_id(drive_id)
    .supports_team_drives(true)
    .supports_all_drives(false)
    .include_items_from_all_drives(true)
    .include_team_drive_items(true)
    .doit()
    .await?;
Bad response
# Sample debug representation of file from response
File { app_properties: None, capabilities: None, content_hints: None, content_restrictions: None, copy_requires_writer_permission: None, created_time: None, description: None, drive_id: Some("drive_id"), explicitly_trashed: None, export_links: None, file_extension: None, folder_color_rgb: None, full_file_extension: None, has_augmented_permissions: None, has_thumbnail: None, head_revision_id: None, icon_link: None, id: Some("id"), image_media_metadata: None, is_app_authorized: None, kind: Some("drive#file"), label_info: None, last_modifying_user: None, link_share_metadata: None, md5_checksum: None, mime_type: Some("application/vnd.google-apps.folder"), modified_by_me: None, modified_by_me_time: None, modified_time: None, name: Some("name"), original_filename: None, owned_by_me: None, owners: None, parents: None, permission_ids: None, permissions: None, properties: None, quota_bytes_used: None, resource_key: None, sha1_checksum: None, sha256_checksum: None, shared: None, shared_with_me_time: None, sharing_user: None, shortcut_details: None, size: None, spaces: None, starred: None, team_drive_id: Some("drive_id"), thumbnail_link: None, thumbnail_version: None, trashed: None, trashed_time: None, trashing_user: None, version: None, video_media_metadata: None, viewed_by_me: None, viewed_by_me_time: None, viewers_can_copy_content: None, web_content_link: None, web_view_link: None, writers_can_share: None }
Working code
let client = reqwest::Client::new();
let mut headers = reqwest::header::HeaderMap::new();
headers
    .insert(
        reqwest::header::AUTHORIZATION,
        format!("Bearer {}", token)
            .parse()
            .unwrap(),
    );
let resp = client.get(format!(
    "https://www.googleapis.com/drive/v2/files?corpora=drive&driveId={drive_id}&includeItemsFromAllDrives=true&includeTeamDriveItems=true&supportsTeamDrives=true",
    drive_id = "drive_id",
))
    .headers(headers.clone())
    .send()
    .await?;
let resp = resp
    .json::<serde_json::Value>()
    .await?;
@Byron
Copy link
Owner

Byron commented May 30, 2024

Thanks for posting! I think it would help to know which version of the code you were using.

Further it would be useful to see which fields had values in the manual request that didn't have them in the response of the generated API. Or alternatively, showing the actual response is better in comparison to showing the expected response.

@cloud303-cholden
Copy link
Author

@Byron My lockfile say the google-drive3 I'm using is 5.0.4+20240227. Here's the log: debug.log. This shows the serde_json::Value of one of the files.

And here is the original File I'm getting from the crate but formatted and with None's removed:

File {
  drive_id: Some("REDACTED"),
  id: Some("REDACTED"),
  kind: Some("drive#file"),
  mime_type: Some("application/vnd.google-apps.folder"),
  name: Some("REDACTED"),
  team_drive_id: Some("REDACTED"),
}

Hope this helps!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants