I am trying to upload a file to Google Drive to a specific folder. Since I need the ID of the folder (not just the name) to set the upload destination (file's parent) I try to search for it by name and get the first returned file's ID from the query below. Instead of a result I get an error:
Google.Apis.Requests.RequestError Invalid Value [400]
Errors [ Message[Invalid Value] Location[q - parameter] Reason[invalid] Domain[global]
at Google.Apis.Requests.ClientServiceRequest`1.Execute()
...
If I try to search for anything really I either get this error or an empty response (i.e. query for all directories mimeType='application/vnd.google-apps.folder'
returns an empty list (doesn't throw an error though)).
The relevant snippet of my code:
FilesResource.ListRequest request = service.Files.List();
request.Q = "title='test_folder'";
string folderId = request.Execute().Files[0].Id; // Error occurs here upon execution
...
fileMeta.Parents = new List<string> { folderId };
The funny thing is, this exact query works on Google's API test site on API v2, but not API v3. The query to get all of the folders works on both though (v2 and v3 on Google's test site), but I get an empty response via my .NET application.
PS: File upload to the "My Drive" directory works, drive services operations like setting the file permissions work etc.
Open to ideas and suggestions on what to check / where I screwed up.