title: Uploading an image to GDrive using API - Python
body: <p>I want to upload aj image to Google Drive. The image is in the same directory of the script i did to upload the image.
  I have this code in a script.py file</p>
  
  <pre><code>#!/usr/bin/python
  
  import httplib2
  import pprint
  from apiclient.discovery import build
  from apiclient.http import MediaFileUpload
  from oauth2client.client import OAuth2WebServerFlow
  
  filename = 'image.jpg'
  mimetype = 'image/jpg'
  
  drive_service = build('drive', 'v2', developerKey='MY Simple API Access KEY')
  
  # Insert a file
  media_body = MediaFileUpload(filename, mimetype=mimetype, resumable=True)
  body = {
      'title': 'This is an image',
      'description': 'This is a description',
      'mimeType': mimetype
  }
  
  file = drive_service.files().insert(body=body, media_body=media_body).execute()
  
  pprint.pprint(file)
  </code></pre>
  
  <p>when running <strong>python script.py</strong> I get this error:</p>
  
  <pre><code>Traceback (most recent call last):
    File "script.py", line 22, in &lt;module&gt;
      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 733, in next_chunk
      raise ResumableUploadError("Failed to retrieve starting URI.")
  apiclient.errors.ResumableUploadError: Failed to retrieve starting URI.
  </code></pre>