title: Put json data into url with python
body: <p>I am trying to encode a json parameter within a url for use with the mongolab restAPI. </p>
  
  <p>My url looks something like this</p>
  
  <pre><code>url = 'https://api.mongolab.com/api/1/databases/db/collections/coll?q={"q": "10024"}&amp;apiKey=mykey 
  </code></pre>
  
  <p>I am trying to open it using</p>
  
  <pre><code>urllib2.urlopen(url)
  </code></pre>
  
  <p>but I run into errors saying that my apikey is incorrect. I know this isn't true because if I copy and paste the url into my browser I get  a correct response. I also know that I can access the rest api as long as I don't have the query there (so it must be a json/formatting problem). </p>
  
  <p>So does anyone know how I could encode the json query</p>
  
  <pre><code>{"q": "10024"} 
  </code></pre>
  
  <p>into the url? Thanks!</p>