title: Upload file to Google Drive with Requests in Python
body: <p>I'm struggling to correctly upload a file to Google Drive through their API. I'm using Python and I'm aware that there is a client library for Google's API. Here is what I currently have. When running the below code, an empty untitled document is created in Google Drive and it's not in the correct directory, <code>root/level_1</code>. I'm not sure what I'm doing wrong with the <code>data</code> and <code>files</code> object. Is there anything that stands out from the code?</p>
  
  <p>Here are the <a href="https://developers.google.com/drive/v2/reference/files/insert" rel="nofollow noreferrer">docs</a> that I was following.</p>
  
  <pre><code>import json
  import requests
  
  url = "https://www.googleapis.com/upload/drive/v2/files?access_token=ACCESS_TOKEN&amp;uploadType=multipart"
  files = {"file": requests.get("image_url").content}
  data = {
      "title": "image_url.jpg",
      "parents": ["root", "level_1"]
  }
  
  response = requests.post(url, data=json.dumps(data), files=files)
  # json.loads(response.text)["title"] = "Untitled"
  return response
  </code></pre>