KoalaTea / google-api-python-client

Automatically exported from code.google.com/p/google-api-python-client
Other
0 stars 0 forks source link

Getting "Failed to retrieve starting URI" when using python quickstart.py #212

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Here is my result:

Traceback (most recent call last):
  File "quickstart.py", line 44, in <module>
    file = drive_service.files().insert(body=body, media_body=media_body).execute()
  File "build/bdist.macosx-10.6-universal/egg/oauth2client/util.py", line 120, in positional_wrapper
  File "build/bdist.macosx-10.6-universal/egg/apiclient/http.py", line 656, in execute
  File "build/bdist.macosx-10.6-universal/egg/oauth2client/util.py", line 120, in positional_wrapper
  File "build/bdist.macosx-10.6-universal/egg/apiclient/http.py", line 733, in next_chunk
apiclient.errors.ResumableUploadError: Failed to retrieve starting URI.

I am running on Ubuntu 12.10 with python 2.7.3

Original issue reported on code.google.com by yuyantin...@gmail.com on 5 Nov 2012 at 8:07

GoogleCodeExporter commented 8 years ago
Sorry the result should be this:

Traceback (most recent call last):
  File "quickstart.py", line 44, in <module>
    file = drive_service.files().insert(body=body, media_body=media_body).execute()
  File "/usr/local/lib/python2.7/dist-packages/google_api_python_client-1.0-py2.7.egg/oauth2client/util.py", line 120, in positional_wrapper
    return wrapped(*args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/google_api_python_client-1.0-py2.7.egg/apiclient/http.py", line 656, in execute
    _, body = self.next_chunk(http=http)
  File "/usr/local/lib/python2.7/dist-packages/google_api_python_client-1.0-py2.7.egg/oauth2client/util.py", line 120, in positional_wrapper
    return wrapped(*args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/google_api_python_client-1.0-py2.7.egg/apiclient/http.py", line 733, in next_chunk
    raise ResumableUploadError("Failed to retrieve starting URI.")
apiclient.errors.ResumableUploadError: Failed to retrieve starting URI.

Original comment by yuyantin...@gmail.com on 5 Nov 2012 at 8:13

GoogleCodeExporter commented 8 years ago
Is the drive API turned on in the APIs Console?

Original comment by jcgregorio@google.com on 16 Nov 2012 at 1:44

GoogleCodeExporter commented 8 years ago

Original comment by jcgregorio@google.com on 16 Nov 2012 at 1:45

GoogleCodeExporter commented 8 years ago
drive API is enabled. Also getting this error. Python 2.7. 

Original comment by andrew.h...@base2s.com on 21 Dec 2012 at 4:34

GoogleCodeExporter commented 8 years ago
When I enable logging, i see this warning: 
WARNING:oauth2client.util:__init__() takes at most 4 positional arguments (5 
given)

Original comment by andrew.h...@base2s.com on 21 Dec 2012 at 4:54

GoogleCodeExporter commented 8 years ago
Belay that, when using my personal Google Apps account this works. So it a 
permission issue with the corporate Google Apps account. 

Original comment by aho...@gmail.com on 21 Dec 2012 at 7:17

GoogleCodeExporter commented 8 years ago
not a corporate/personal permissions issue....

Original comment by vfe.stev...@jabil.com on 27 Dec 2012 at 8:01

GoogleCodeExporter commented 8 years ago
I'm also getting this error when following the Quickstart guide. Has there been 
any progress?

Original comment by tim.og...@techota.com on 15 Jan 2013 at 4:57

GoogleCodeExporter commented 8 years ago
I take my comment back, my issue did turn out to be a setting but nothing to do 
with the APIs Console (Third party drive apps we're not allowed in CPanel). 
With the dev domain and a personal account this worked without an issue.

Original comment by vfe.stev...@jabil.com on 15 Jan 2013 at 6:30

GoogleCodeExporter commented 8 years ago
Sorry, I'm not able to reproduce this bug.

Go here and use the Quickstart experience, choosing Drive as the API and Cmd 
line as the application type:

   https://developers.google.com/api-client-library/python/start/installation

Then, at the point in sample.py where it says 
    print "Success! Now add code here."
insert the following code below it:

    from apiclient.http import MediaIoBaseUpload
    media_body = MediaIoBaseUpload(file("someimage.JPG", "r"), "image/jpeg", resumable=True)
    service.files().insert(body={}, media_body=media_body).execute()

Obviously change "someimage.JPG" to your own file to upload.

Original comment by jcgregorio@google.com on 15 Jan 2013 at 6:53

GoogleCodeExporter commented 8 years ago
I think I've figured it out. Doing what you suggested allowed the 
authentication process to complete successfully. However, the same error 
occurred once it got to the upload stage.

When I replaced resumable=True with resumable=False in the MediaIoBaseUpload 
method, I received a different error:

Traceback (most recent call last):
  File "sample.py", line 141, in <module>
    main(sys.argv)
  File "sample.py", line 121, in main
    service.files().insert(body={}, media_body=media_body).execute()
  File "/home/timoguin/dev/admin/google_apps/drive-v2-python-cmd-line/oauth2client/util.py", line 120, in positional_wrapper
    return wrapped(*args, **kwargs)
  File "/home/timoguin/dev/admin/google_apps/drive-v2-python-cmd-line/apiclient/http.py", line 678, in execute
    raise HttpError(resp, content, uri=self.uri)
apiclient.errors.HttpError: <HttpError 403 when requesting 
https://www.googleapis.com/upload/drive/v2/files?uploadType=multipart&alt=json 
returned "The domain policy has disabled third-party Drive apps">

Seems the resumable argument is masking the real error and making it difficult 
to troubleshoot.

I went into the Google Apps backend and enabled the Chrome Web Store service, 
but I'm still getting the same errors. Is there some other service I need to 
enable?

Original comment by tim.og...@techota.com on 15 Jan 2013 at 7:18

GoogleCodeExporter commented 8 years ago
It's worth noting that I get different errors when trying to upload a picture 
versus a document.

Using the following line to upload an image:

media_body = MediaIoBaseUpload(file("picture.jpg", "r"), "image/jpeg", 
resumable=False)

I get the following stack trace:

Traceback (most recent call last):
  File "sample.py", line 141, in <module>
    main(sys.argv)
  File "sample.py", line 121, in main
    service.files().insert(body={}, media_body=media_body).execute()
  File "/home/timoguin/dev/admin/google_apps/drive-v2-python-cmd-line/oauth2client/util.py", line 120, in positional_wrapper
    return wrapped(*args, **kwargs)
  File "/home/timoguin/dev/admin/google_apps/drive-v2-python-cmd-line/apiclient/http.py", line 676, in execute
    headers=self.headers)
  File "/home/timoguin/dev/admin/google_apps/drive-v2-python-cmd-line/oauth2client/util.py", line 120, in positional_wrapper
    return wrapped(*args, **kwargs)
  File "/home/timoguin/dev/admin/google_apps/drive-v2-python-cmd-line/oauth2client/client.py", line 420, in new_request
    redirections, connection_type)
  File "/home/timoguin/dev/admin/google_apps/drive-v2-python-cmd-line/httplib2/__init__.py", line 1588, in request
    (response, content) = self._request(conn, authority, uri, request_uri, method, body, headers, redirections, cachekey)
  File "/home/timoguin/dev/admin/google_apps/drive-v2-python-cmd-line/httplib2/__init__.py", line 1336, in _request
    (response, content) = self._conn_request(conn, request_uri, method, body, headers)
  File "/home/timoguin/dev/admin/google_apps/drive-v2-python-cmd-line/httplib2/__init__.py", line 1273, in _conn_request
    conn.request(method, request_uri, body, headers)
  File "/usr/lib/python2.7/httplib.py", line 958, in request
    self._send_request(method, url, body, headers)
  File "/usr/lib/python2.7/httplib.py", line 992, in _send_request
    self.endheaders(body)
  File "/usr/lib/python2.7/httplib.py", line 954, in endheaders
    self._send_output(message_body)
  File "/usr/lib/python2.7/httplib.py", line 812, in _send_output
    msg += message_body
UnicodeDecodeError: 'ascii' codec can't decode byte 0xff in position 209: 
ordinal not in range(128)

However, using this line to upload to text file:

media_body = MediaIoBaseUpload(file("document.txt", "r"), "text/plain", 
resumable=False)

I get the stack trace that I posted in my previous comment.

If resumable is set to true, I receive the original error for both images and 
documents.

Original comment by tim.og...@techota.com on 15 Jan 2013 at 7:33

GoogleCodeExporter commented 8 years ago
The ascii codec issue is a known one and has been fixed in head. It will go out 
in the next release.

 https://code.google.com/p/google-api-python-client/issues/detail?id=131

Original comment by jcgregorio@google.com on 15 Jan 2013 at 7:36

GoogleCodeExporter commented 8 years ago
I also get the error when I run the quickstart.py from:
https://developers.google.com/drive/quickstart-python

I have enabled Drive API, and replace my client ID and secrect.
I run it on Windows7, please resolve the issue.

Original comment by mjq...@motorola.com on 28 Feb 2013 at 11:43

GoogleCodeExporter commented 8 years ago
When I use corporate account, the quickstart.py report the error :
apiclient.errors.ResumableUploadError: Failed to retrieve starting URI.

But when I use my private gmail account, the quickstart.py can upload 
document.txt.
Why?
Please resolve the issue ASAP.

Original comment by mjq...@motorola.com on 1 Mar 2013 at 1:56

GoogleCodeExporter commented 8 years ago
Issue 250 has been merged into this issue.

Original comment by dhermes@google.com on 20 Mar 2013 at 2:33

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
Thanks for the workaround jcgregorio. I was able to complete authentication, 
but file upload was not successful.

Running sample.py with resumable=False uploads a corrupted file. Running it 
with resumable=True results in a ~10 minute delay and then the following 
traceback:

C:\Users\Will\Downloads\Coding Shit\drive-v2-python-cmd-line>sample.py
Traceback (most recent call last):
  File "C:\Users\Will\Downloads\Coding Stuff\drive-v2-python-cmd-line\sample.py",
 line 141, in <module>
    main(sys.argv)
  File "C:\Users\Will\Downloads\Coding Stuff\drive-v2-python-cmd-line\sample.py",
 line 120, in main
    service.files().insert(body={}, media_body=media_body).execute()
  File "C:\Users\Will\Downloads\Coding Stuff\drive-v2-python-cmd-line\oauth2clien
t\util.py", line 120, in positional_wrapper
    return wrapped(*args, **kwargs)
  File "C:\Users\Will\Downloads\Coding Stuff\drive-v2-python-cmd-line\apiclient\h
ttp.py", line 656, in execute
    _, body = self.next_chunk(http=http)
  File "C:\Users\Will\Downloads\Coding Stuff\drive-v2-python-cmd-line\oauth2clien
t\util.py", line 120, in positional_wrapper
    return wrapped(*args, **kwargs)
  File "C:\Users\Will\Downloads\Coding Stuff\drive-v2-python-cmd-line\apiclient\h
ttp.py", line 784, in next_chunk
    headers=headers)
  File "C:\Users\Will\Downloads\Coding Stuff\drive-v2-python-cmd-line\oauth2clien
t\util.py", line 120, in positional_wrapper
    return wrapped(*args, **kwargs)
  File "C:\Users\Will\Downloads\Coding Stuff\drive-v2-python-cmd-line\oauth2clien
t\client.py", line 420, in new_request
    redirections, connection_type)
  File "C:\Users\Will\Downloads\Coding Stuff\drive-v2-python-cmd-line\httplib2\__
init__.py", line 1588, in request
    (response, content) = self._request(conn, authority, uri, request_uri, metho
d, body, headers, redirections, cachekey)
  File "C:\Users\Will\Downloads\Coding Stuff\drive-v2-python-cmd-line\httplib2\__
init__.py", line 1336, in _request
    (response, content) = self._conn_request(conn, request_uri, method, body, he
aders)
  File "C:\Users\Will\Downloads\Coding Stuff\drive-v2-python-cmd-line\httplib2\__
init__.py", line 1306, in _conn_request
    response = conn.getresponse()
  File "C:\Python27\lib\httplib.py", line 1025, in getresponse
    response.begin()
  File "C:\Python27\lib\httplib.py", line 401, in begin
    version, status, reason = self._read_status()
  File "C:\Python27\lib\httplib.py", line 365, in _read_status
    raise BadStatusLine(line)
httplib.BadStatusLine: ''

Original comment by Maner.Ca...@gmail.com on 20 Mar 2013 at 3:16

GoogleCodeExporter commented 8 years ago
This question is probably better suited for the Drive team.

Existing questions: http://stackoverflow.com/questions/tagged/google-drive-sdk

To ask a question tagged with Google Drive SDK: 
http://stackoverflow.com/questions/ask?tags=google-drive-sdk

Original comment by dhermes@google.com on 20 Mar 2013 at 5:46