New file?

14 views
Skip to first unread message

Booker

unread,
Jan 27, 2018, 9:48:44 PM1/27/18
to gshell-discuss
I feel like I've lost the battle writing this. I'm a hobbyist POSH'er and brand new tonight to API's. I've got the Google API keys setup, API's activated and successfully downloaded files from Drive to the PC via Export-GDriveFile. I thought I was winning! But my real requirement is to update a Google Sheet row by row as data is processed via POSH. I can't see references to Sheets API on your Git page (or here) so my first question is:

Does Update-GDriveFile allow me to do this?

If not, as a fallback, I could upload a complete txt/csv instead but I can't get my head around New-GDriveFileObj, specifically, where does the content go? I've tried New-GDriveFileObj -OriginalFilename "henry.txt" -Name "henry" -FileExtension "txt" -FullFileExtension "txt" -OwnedByMe 1 but it doesn't even show as a file on Drive.

If you could share some basic examples of usage of the above cmdlets, it would help tremendously those that learn by copy, paste, try (like me).

PS I commend you on everything you've done on this project and I'm sorry to ask such a basic question.

Spencer Varney

unread,
Jan 29, 2018, 9:55:30 AM1/29/18
to Booker, gshell-discuss
Hey Booker,

I'll have to get back to you on some examples of how to use New-GDriveFileObj, I'm not in a spot where I can test and verify that at the moment. So on to the next bit...

So from my understanding of things, this wouldn't be the way to go about things. The Google Drive v3 API will allow you to do things like download and upload entire files, but not get parts of the file or update lines therein. To do that, you'd need to look in to using the Google Apps Script which does let you interact with the spreadsheet.

Thing is, Google Apps Script is like writing a VB script for an Excel macro - it works within the browser and within the sheet. I don't have a ton of experience with it, but I have written a few to do some extensions for spreadsheets.

So, can you then take Google Apps Script (Javascript) and somehow interact with it via PoSh? Well... it gets even more hairy. They do provide an Apps Script API to 'remotely execute a specified Apps Script function' which is itself also a REST API, and they also offer a C# example in the API request examples section which I think would rely on the Google Apis Script v1 client library. I have gone no further than that, however I do think that's the appropriate direction to go.

To get started right now you'd have to figure out a way to convert the client library in to PoSh cmdlets, or to do it in a way that it would work with gShell.

OR

As per a previous thread I'm currently working on a way to automate the conversion of any and all C# google client libraries in to a gShell module. Depending on your timeline, I'd be happy to make this one of the ones I look in to first.

Also note: I see from a quick search there is also a Sheets v4 API but the release notes are old and their documentation is limited. Again, once I have been able to generate the PoSh module around it I'll have a better idea of what it can and can't do.

I'll be back with examples hopefully later today.

Regards,

Spencer

--
You received this message because you are subscribed to the Google Groups "gshell-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gshell-discus...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages