Sketchup 2017 encode form data

I’m wondering if anyone knows of an alternative to URI.encode_www_form?

puts URI.encode_www_form([["grant_type", "password"], ["username", "my name"], ['password', '!@#garbage']])

#expected result => grant_type=password&username=my+name&password=%21%40%23garbage

# SU 2017 result => Error: #<NameError: uninitialized constant URI>

With Windows & SU 2017 below works?

require 'uri'
1 Like

Easy enough!

Whenever you get a NameError, it’s either a typo or a file / library that defines the object, isn’t yet loaded.

Go to the core doc entry page, and scroll down to see the list of core classes and modules:

URI is not there so it’s not core. So it must either be standard library or rubygem.

You scroll back to the top of the page and you’ll find a link to the Standard Library. Click that and scroll down the left navbar and you find it. Libraries need to be loaded.

1 Like