Dynamic folder path in GDrive module

I am trying to upload a file generated in a previous step to my Google Drive. I tested the scenario with a static target folder location and it works. I want to make the Gdrive folder path dynamic based on a variable, f.i. /My Drive/Folder1/Folder2/{{MyDynamicFolder}}

When I run a test, I can see I built the correct folder path but I get the error message in GDrive module: " RuntimeError [404] File not found: /Automation /FASTest/MyDynamicFolder/."

In “New Folder Location”, I tried building the path with/without “My Drive”:
/My Drive/Folder1/Folder2/{{MyDynamicFolder}}
/Folder1/Folder2/{{MyDynamicFolder}}

I checked spelling and case sensitive and it looks good. Attached screenshots. Appreciate any hint!


Hello! Welcome to the Make Community.

I think you need first to create the Folder with “Google Drive / Create a Folder”. For the Path, do the same as you did in “Upload a File”. It will return the ID of the new folder. In “Upload a File”, do the same as before, but use the ID you got from “Create a Folder” instead.

I’m not 100% sure whether you need the ID or the Folder Name

Tell me if it worked.

Cheers

Benjamin

Thanks Benjamin for your reply!

The folders already exist. I can make it work with the folder ID, that’s not the issue. My use case is different. I want to dynamically construct the folder path for the File Upload action in the GDrive module. It would help to know if this is supported.

Hi @Fabrice_Talbot,

sorry I misunderstood.
Apparently, the Google “Upload a File” expects a folder id, and not a path. You try and use Google Drive / “Get a Folder id for a Path” and map the path the same way you did (starting with /Automation…). It will provide you a Folder ID variable that you can map in “New Folder Location” of “Upload a File”.

Also, we can see a space after /Automation, I’m not sure it can work like this. Maybe you need to remove the space in the name, maybe you need to replace it with %20, or maybe it’s just a typo for the screenshot?

Benjamin

There is indeed a space after Automation, again I don’t know how Make handles space. Google does not ask you to escape the string, it’s natively supported.

The question is simple: do you provide string-based folder path? If not, I recommend you pass this as a feature request to your product manager. For an automation company, it feels odd to ask for hard coded ID… Since this is part of your builder, it’d be a nice enhancement and I believe this is a pattern used in many modules.

The space was just an idea to try and help you… Make does support spaces, and uses URL encoding when necessary, or provides an encoding function in case we have to escape any special character that would break API calls if the path has to be used in the URL or query parameters.

Now, the Google Drive API to upload a file doesn’t accept paths, but only Folders ID (in a ‘Parents’ collection in the body of the request); it’s the way the Google API is built. To help users, and since Make is an integration company, the use of folder path in the module is here to facilitate the mappings. It then transforms this path into a Folder ID under the hood.

And, if you need to use the ID instead, nothing is hard-coded, it’s just a matter of mapping the relevant ID, which is dynamic according to the folder you want to put the file in. Make provides a module to help convert a folder path to an ID so that you can dynamically select folders. So, nothing is hard-coded.

So, the simple answer is: the Google Drive Upload endpoint expects a FolderID and not a path; so if you need to map to a dynamic folder instead of setting it at design time, you need to find the FolderID first, and then map it in the Upload a File module. => The solution I proposed.

Anyway, letting users use folders (even dynamic) and having the module convert it to an ID is a good idea, I will propose this as a new feature. If you could ask Google in parallel to provide an endpoint that accepts folder names, it would be good :slight_smile:

This is super helpful! I’ll try a function to map the folder path to a folder ID.

1 Like

@Fabrice_Talbot i’m happy you like it. Let me know if you are stuck anywhere.

Benjamin