試圖讓它在共享的 Google Drive 上作業,我最初能夠得到 200 個回應,但該檔案夾從未寫在我能找到的任何地方。所以我添加了父級,現在我收到 404 錯誤。
{
"error": {
"errors": [
{
"domain": "global",
"reason": "notFound",
"message": "File not found: [FileId].",
"locationType": "parameter",
"location": "fileId"
}
],
"code": 404,
"message": "File not found: [FileId]."
}
}
Dim gAuth As New Chilkat.AuthGoogle
gAuth.AccessToken = GetGoogleAccessToken()
Dim rest As New Chilkat.Rest
' Connect using TLS.
Dim bAutoReconnect As Boolean = True
success = rest.Connect("www.googleapis.com", 443, True, bAutoReconnect)
' Provide the authentication credentials (i.e. the access token)
rest.SetAuthGoogle(gAuth)
' A multipart upload to Google Drive needs a multipart/related Content-Type
rest.AddHeader("Content-Type", "multipart/related")
' Specify each part of the request.
' The 1st part is JSON with information about the folder.
rest.PartSelector = "1"
rest.AddHeader("Content-Type", "application/json; charset=UTF-8")
Dim json As New Chilkat.JsonObject
json.AppendString("name", fFolderName)
json.AppendString("description", "A folder to contain test files.")
json.AppendString("mimeType", "application/vnd.google-apps.folder")
Dim folderId As String = "[folderId confirmed to be working]"
Dim parents As Chilkat.JsonArray = json.AppendArray("parents")
parents.AddStringAt(-1, folderId)
rest.SetMultipartBodyString(json.Emit())
' The 2nd part would be the file content.
' Since this is a folder, skip the 2nd part entirely and go straight to the upload..
Dim jsonResponse As String = rest.FullRequestMultipart("POST", "/upload/drive/v3/files?uploadType=multipart")
If (rest.LastMethodSuccess <> True) Then
Console.WriteLine(rest.LastErrorText)
Return False
Exit Function
End If
' A successful response will have a status code equal to 200.
If (rest.ResponseStatusCode <> 200) Then
Console.WriteLine("response status code = " & rest.ResponseStatusCode)
Console.WriteLine("response status text = " & rest.ResponseStatusText)
Console.WriteLine("response header: " & rest.ResponseHeader)
Console.WriteLine("response JSON: " & jsonResponse)
Return False
Exit Function
End If
我看到很多事情圍繞著答案嗡嗡作響,但似乎無法得到這個。我看到了添加supportsAllDrives=True,但不知道在哪里添加......
uj5u.com熱心網友回復:
所以,我需要添加共享檔案夾的父檔案夾ID

我需要為要在共享驅動器上創建的檔案添加這兩行。

轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/443719.html
下一篇:如何在Python中使用數學函式
