I'm working with the TCL syntax for uploading a file to a Google Drive subdirectory using cURL. Based on documentation there is a property called parent that holds the subfolder id. It works fine in the "Try the API section" - and my code below works fine if I remove the parents parameter (then, the file is uploaded to the GDrive root folder).
This is how the parameter should look like based on documentation:
parents : [{"id" : "0B-b5yS-0xCQjVEcyMm9hYmtqd0k"}]
Now I want to adapt this to my current code but it errors occur. I assume the issue is related to TCL syntax, but as I'm not that familiar with the language I'm completely lost now after spending hours with try&error to get it working. What I try to do is to set a parameter fileMetaData that holds all necessary values for the metadata (so even the parent folder list), furthermore I define a parameter curlCommand that stores the final cURL statement. Within that curlCommand I provide the fileMetaData and finally I execute the command with cURL within an eval exec statement.
I think it is related to substitution? But I'm really lost. I've tried it with double-quotes and even with backslashes before the curly braces and the square brackets. I always get an error.
This is the current code:
set fileMetaData "metadata={name : '$backupFile', title : '$fileName', \
description : 'Backup file from $today', \
parents : [{id : '0B-b5yS-0xCQjVEcyMm9hYmtqd0k'}] }"
set curlCommand "-H \"GData-Version: 3.0\" \
-H \"Authorization: Bearer $accessToken\" \
-F \"$fileMetaData;type=application/json;charset=UTF-8\" \
-F \"file=@$backupFile\" \
https://www.googleapis.com/upload/drive/v2/files?uploadType=multipart"
catch { eval exec /usr/local/addons/prtz/curl -k $curlCommand}
The error message I get while running the code is:
invalid command name "id: '0B-b5yS-0xCQjVEcyMm9hYmtqd0k'"
while executing "{id: '0B-b5yS-0xCQjVEcyMm9hYmtqd0k'}"
Maybe important: I strictly have to use native TCL 8.2 without any additional libraries (i.e. for JSON support). I appreciate any input that helps to figure how to solve!
Thanks.