Reputation: 215
I want to insert file in folder, after searching in this page , i try to do it
there is my code :
'folder creation
Dim dossier = New Google.Apis.Drive.v2.Data.File()
dossier.Title = dat_sauv.SelectedItem
dossier.MimeType = "application/vnd.google-apps.folder"
Dim rep = Service.Files.Insert(dossier)
rep.Fields = "id"
Dim ref As New ParentReference()
ref.Id = dossier.Id
MessageBox.Show(dossier.Id)
Dim file = rep.Execute()
' file creation
Dim f As New Google.Apis.Drive.v2.Data.File()
f.Title = fichier_txt.Text
f.Description = " fichier drive"
f.MimeType = "text/plain , image/jpeg"
Dim s As Integer
s = f.Id
Try
Dim r = Service.Parents.Insert(ref, s).Execute()
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
but the error is :
and i can't resolve this error. and when i change the type of s to string , the error message is :
Upvotes: 3
Views: 281
Reputation: 8082
AFAIK, import operations will return a 400 error if the file format is not supported. With this, you may want to try specifying file names and extensions.
Apps should specify a file extension in the title property when inserting files with the API. For example, an operation to insert a JPEG file should specify something like
"name": "cat.jpg"
in the metadata.
Also, noted in Files: insert
,
Apps creating shortcuts with
files.insert
must specify the MIME typeapplication/vnd.google-apps.drive-sdk
.
Lastly, see also Migrating from Google Drive API v2 for more information.
Upvotes: 1