views:

45

answers:

2

Hi, I'm using django-googlecharts to generate a simple pie chart. Inside the img tag, it works just fine, but if I paste the img src in the location bar of the browser, google returns "Bad Request", "Your client has issued a malformed or illegal request".

I followed the example in the django-googlecharts documentation here:

http://github.com/jacobian/django-googlecharts/blob/master/docs/examples.html

and actually, these examples from the documentation have the same problem. So, for example:

<img src="http://chart.apis.google.com/chart?chs=300x200&amp;amp;cht=p&amp;amp;chl=One|Two|Three&amp;amp;chd=e:VVqq.." width="300" height="200" alt="It worked!" />

works fine in the web page, but the src cut and pasted into the browser location bar does not:

http://chart.apis.google.com/chart?chs=300x200&amp;amp;cht=p&amp;amp;chl=One|Two|Three&amp;amp;chd=e:VVqq..

I don't know if this is an encoding problem or something else. I've been trying to embed these charts in an HTML email without luck, and I'm wondering if figuring this part out will lead to solution. Thanks for your help!

+1  A: 

You've got HTML entities in the URL. Just use an HTML entity decoder:

http://chart.apis.google.com/chart?chs=300x200&amp;cht=p&amp;chl=One|Two|Three&amp;chd=e:VVqq.

That's the HTML entity decoded version of the URL that you have above. Just run it through the decoder I've linked.

Hope this helps!

mattbasta
+1  A: 

The browser interprets the escaped ampersands &amp; into real ampersands & when used in an image tag, but not when directly put into the address bar.

The url http://chart.apis.google.com/chart?chs=300x200&amp;cht=p&amp;chl=One|Two|Three&amp;chd=e:VVqq.. works just fine in the browser.

Nick Canzoneri
Oh man, I should have looked more closely. Thanks very much.
asciitaxi