How can I import/export settings into a file?

For future reference some problems I had using discourse-settings-uploader, getting 301 errors:

./discourse-settings-uploader community.mysite.com 22f7d44321ae2365d3e3a5e9224524ba0e7302bd75ed06bfbh31ed5090ec6d3b system site-settings.json
SiteSettingtitle="Mysite"
E! 301 Moved Permanently

I get this error once for each setting. But I can browse the site successfully at those URLs. So I figured out - it’s going through http, and that is disabled.

So now I add https to my site name and I get a different error:

SiteSettingtitle="My sIte"
E! SSL_connect returned=1 errno=0 state=error: certificate verify failed (unable to get local issuer certificate)
something's wrong with https://community.mysite.com/admin/site_settings/title {"title"=>"Mysite", :api_key=>"22f7d44321ae2365d3e3a5e9224524ba0e7302bd75ed06bfbh31ed5090ec6d3b ec6d3b", :api_username=>"system"}

So this boils down to a deficient local configuration of root certificates, it seems. I could go off and waste an afternoon on this, but instead what I did was turn off verify_ssl. It’s very insecure and horrible things will happen to you and your children and your children’s children but for this case, I just didn’t care.

So in the uploader script I added this method:

def put_no_ssl(url, payload, headers={}, &block)
  RestClient::Request.execute(method: :put, url: url, :payload => payload, headers: headers, verify_ssl: false, &block)
end

And below, I changed the call from

r = RestClient.put(url, my_hash)

to

r = put_no_ssl(url, my_hash)

And it worked! :sunglasses: