小编And*_*rea的帖子

Google Client API v3 - 使用 Python 更新驱动器上的文件

我正在尝试使用 google 客户端 api 从 python 脚本更新文件的内容。问题是我一直收到错误 403:

An error occurred: <HttpError 403 when requesting https://www.googleapis.com /upload/drive/v3/files/...?alt=json&uploadType=resumable returned "The resource body includes fields which are not directly writable.
Run Code Online (Sandbox Code Playgroud)

我试图删除元数据字段,但没有帮助。

更新文件的函数如下:

# File: utilities.py
from googleapiclient import errors
from googleapiclient.http import MediaFileUpload
from googleapiclient.discovery import build
from httplib2 import Http
from oauth2client import file, client, tools

def update_file(service, file_id, new_name, new_description, new_mime_type,
            new_filename):
"""Update an existing file's metadata and content.

Args:
    service: Drive API service instance.
    file_id: ID of the file …
Run Code Online (Sandbox Code Playgroud)

python google-api google-drive-api google-api-python-client

4
推荐指数
1
解决办法
2601
查看次数