Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8089439
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T19:23:44+00:00 2026-06-05T19:23:44+00:00

import httplib2 from urllib import urlencode h = httplib2.Http() h.add_credentials(‘zackster@gmail.com’, ‘PassWord’) data = dict(key=ThisIsMyApiKeyICopiedAndPastedIt)

  • 0
import httplib2
from urllib import urlencode
h = httplib2.Http()
h.add_credentials('zackster@gmail.com', 'PassWord')
data = dict(key="ThisIsMyApiKeyICopiedAndPastedIt")
resp, content = h.request("https://www.googleapis.com/calendar/v3/users/me/calendarList", "GET", urlencode(data), headers={'content-type':'text/plain'})



>>> resp
{'date': 'Wed, 13 Jun 2012 04:33:03 GMT', 'status': '400', 'content-length': '925', 'content-type': 'text/html; charset=UTF-8', 'server': 'GFE/2.0'}

>>> print content

<!DOCTYPE html>
<html lang=en>
  <meta charset=utf-8>
  <meta name=viewport content="initial-scale=1, minimum-scale=1, width=device-width">
  <title>Error 400 (Bad Request)!!1</title>
  <style>
    *{margin:0;padding:0}html,code{font:15px/22px arial,sans-serif}html{background:#fff;color:#222;padding:15px}body{margin:7% auto 0;max-width:390px;min-height:180px;padding:30px 0 15px}* > body{background:url(//www.google.com/images/errors/robot.png) 100% 5px no-repeat;padding-right:205px}p{margin:11px 0 22px;overflow:hidden}ins{color:#777;text-decoration:none}a img{border:0}@media screen and (max-width:772px){body{background:none;margin-top:0;max-width:none;padding-right:0}}
  </style>
  <a href=//www.google.com/><img src=//www.google.com/images/errors/logo_sm.gif alt=Google></a>
  <p><b>400.</b> <ins>That’s an error.</ins>
  <p>Your client has issued a malformed or illegal request.  <ins>That’s all we know.</ins>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T19:23:46+00:00Added an answer on June 5, 2026 at 7:23 pm

    I’m guessing, but you are sending your API key as POST data. It needs to be appended to the URL as a query string. This is the HTTP request generated by your code:

    GET /calendar/v3/users/me/calendarList HTTP/1.1
    Host: www.googleapis.com
    Content-Length: 36
    content-type: text/plain
    accept-encoding: gzip, deflate
    user-agent: Python-httplib2/$Rev$
    
    key=ThisIsMyApiKeyICopiedAndPastedIt
    

    Rather (if my guess is right) it should be:

    GET /calendar/v3/users/me/calendarList?key=ThisIsMyApiKeyICopiedAndPastedIt HTTP/1.1
    Host: localhost:1234
    content-type: text/plain
    accept-encoding: gzip, deflate
    user-agent: Python-httplib2/$Rev$
    

    So your code should be modified to something like this:

    url = 'https://www.googleapis.com/calendar/v3/users/me/calendarList'
    uri = '%s?%s' % (url, urlencode(data))
    resp, content = h.request(uri, "GET", headers={'content-type':'text/plain'})
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Why isn't this simple Python code working? import urllib file = urllib.urlopen('http://www.google.com') print file.read()
I'm trying to make an http request using httplib2: import httplib2, time, re, urllib`
I found this script online: import httplib, urllib params = urllib.urlencode({'number': 12524, 'type': 'issue',
import MySQLdb import sys from libdesklets.controls import Control from IDBConnection import IDBConnection class DBConnection(Control,
I' getting the following error while trying to run my application from oauth2client.appengine import
I'm writing a pythonic web API wrapper with a class like this import httplib2
After somes problems with a simple import of httplib2 (see my post here ),
i am trying this python script: import httplib import urllib conn = httplib.HTTPConnection(moodle.tau.ac.il) conn.request(POST
I'm building an application in Python2.6 that needs to get data from CouchDb. I'm
I'm playing with the Python library httplib2 . The following is my code. import

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.