ruby-samples
ruby-samples copied to clipboard
Create empty file
I was looking at the spreadsheet api documentation and saw that it is possible to create an empty file using Divre API https://developers.google.com/sheets/api/guides/create#work_with_google_drive_folders
but I didn't find exactly in that step in that repository
anyway, I tried this code taken from the examples in that repository:
file_metadata = { name: "My new Sheet #{Time.now.strftime('%d/%m/%Y %H:%M')}",
mimeType: 'application/vnd.google-apps.spreadsheet' }
file = drive_service.create_file(file_metadata)
but I always get this error:
Traceback (most recent call last):
2: from quickstart.rb:80:in `<main>'
1: from quickstart.rb:60:in `create_file'
/home/vagrant/.rvm/gems/ruby-2.7.2/gems/google-api-client-0.53.0/generated/google/apis/drive_v3/service.rb:895:in `create_file': unknown keywords: :name, :mimeType (ArgumentError)
How could I make this work?
Expected Behavior
The file created successfully
Actual Behavior
Error:
Traceback (most recent call last):
2: from quickstart.rb:80:in `<main>'
1: from quickstart.rb:60:in `create_file'
/home/vagrant/.rvm/gems/ruby-2.7.2/gems/google-api-client-0.53.0/generated/google/apis/drive_v3/service.rb:895:in `create_file': unknown keywords: :name, :mimeType (ArgumentError)
Steps to Reproduce the Problem
1.Create a new instance of google drive service (I did this based on: Ruby quickstart)
2. Use the method create_file passing file_metadata
Specifications
- Ruby version (2.7.2)
- OS (Linux)