Last Updated: February 25, 2016
·
517
· gwinn

Uri.encode vs. uri-handler to_uri method

Well, when i'm trying to pass some difficult parameters to my get request, like a json:

http://myapisite.com/api/action?data={"username" : "test", "password" : "test", "domains" : [{"dname" : "test.com"}, {"dname" : "test.com"}], "subdomain" : "tt", "dns_server" : "ns1.test.com", "record_number" : "10"}

i noticed that Uri.encode does not cope with the transformation of ':' & '[]' characters, so, if you doesn't want retrieve an error like "Bad URL (not url)", i'll recommend you to use url-handler gem and it's method .to_uri