HTTPerror 400无效上传请求:尝试上传文件的示例代码到Google云端硬盘

时间:2012-12-27 05:42:05

标签: google-drive-api

我正在尝试Google Drive API的快速入门部分中的示例代码,我收到以下错误:\

Traceback (most recent call last):
  File "quickstart.py", line 60, in <module>
    file = drive_service.files().insert(body=body, media_body=media_body).execute()
  File "/usr/local/lib/python2.7/dist-packages/oauth2client/util.py", line 120, in positional_wrapper
    return wrapped(*args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/apiclient/http.py", line 656, in execute
    _, body = self.next_chunk(http=http)
  File "/usr/local/lib/python2.7/dist-packages/oauth2client/util.py", line 120, in positional_wrapper
    return wrapped(*args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/apiclient/http.py", line 789, in next_chunk
    return self._process_response(resp, content)
  File "/usr/local/lib/python2.7/dist-packages/apiclient/http.py", line 816, in _process_response
    raise HttpError(resp, content, uri=self.uri)
apiclient.errors.HttpError: <HttpError 400 when requesting https://www.googleapis.com/upload/drive/v2/files?uploadType=resumable&alt=json returned "Invalid Upload Request">

我正在使用示例代码,没有任何更改。昨天相同的代码工作,但今天它不工作..这是一个服务器端错误?

1 个答案:

答案 0 :(得分:2)

指定不存在的文件时遇到同样的错误。请尝试指定上传文件的完整路径。