Byron / google-apis-rs

A binding and CLI generator for all Google APIs
http://byron.github.io/google-apis-rs
Other
983 stars 132 forks source link

Google Drive V3 `FileListCall` Missing Data #501

Open cloud303-cholden opened 1 month ago

cloud303-cholden commented 1 month ago

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 ```rust 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 ```sh # 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 ```rust 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::() .await?; ```
Byron commented 1 month ago

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 commented 1 month ago

@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!