Reputation: 27852
I have a URI like this:
And I try this:
require 'open-uri'
open "https://chart.googleapis.com/chart?cht=lc&chd=s:cEAELFJHHHKUju9uuXUc&chco=76A4FB&chls=2.0&chs=220x125&chxt=x,y&chxr=1,0,4&chxl=3:|Jan|Feb|Mar&chxs=2,0000dd,13,-1,t,FF0000&chxp=2,10,35,95&chxtc=1,5,15"
And I get the following message:
URI::InvalidURIError: bad URI(is not URI?):
What should I do?
Upvotes: 1
Views: 616
Reputation: 16012
The pipes are causing your problem. They have to be percent encoded.
You may work around this by
uri = "https://chart.googleapis.com/chart?cht=lc&chd=s:cEAELFJHHHKUju9uuXUc&chco=76A4FB&chls=2.0&chs=220x125&chxt=x,y&chxr=1,0,4&chxl=3:|Jan|Feb|Mar&chxs=2,0000dd,13,-1,t,FF0000&chxp=2,10,35,95&chxtc=1,5,15"
uri.gsub!('|', '%7C')
open uri
Upvotes: 3