I am using google form to upload files to google drive. Now I want to be able to upload these (uploaded)files from google drive to external api using google apps script. (This api of GoCD to be specific.)
I tried to upload the file this way which is probably wrong, but it doesn't work:
function main() {
var url = "https://<my-server-url>/go/files/Pipeline1/1/Stage1/1/Job1/folder/";
var form = {
file : DriveApp.getFileById("<file-id>"),
};
uploadFile(url,form);
}
function uploadFile(url,form) {
var options = {
"method" : "POST",
"header" : {
"Confirm" : true
},
"muteHttpExceptions" : true,
'zipFile' : form
};
var response = UrlFetchApp.fetch(url,options);
Logger.log("Response body: " + response.getContentText());
}
Is there any other way to make POST api call to upload files from drive? Also, any help with resources for doPost() method of google apps script will be appreciated.