Skip to content

Instantly share code, notes, and snippets.

@sepulworld
Last active October 15, 2021 20:08
Show Gist options
  • Save sepulworld/21106fa2551353bcc1b7 to your computer and use it in GitHub Desktop.
Save sepulworld/21106fa2551353bcc1b7 to your computer and use it in GitHub Desktop.
httparty post json array to Aptly
#!/bin/ruby
include HTTParty
fields = []
fields << {"Name" => "rocksoftware22", "Component" => "precise4"}
fields << {"Name" => "rocksoftware", "Component" => "precise5"}
params_hash ={}
params_hash[:Sources] = fields
params_hash[:SourceKind] = "local"
params_hash[:Distribution] = "binary1"
params_hash.to_json
@result = HTTParty.post("http://127.0.0.1:8082/api/publish", :headers => {'Content-Type'=>'application/json'}, :body => params_hash.to_json,)
#root@vagrant-ubuntu-precise-64:~# aptly publish list
#Published repositories:
# * ./binary1 [amd64, i386] publishes {precise4: [rocksoftware22]}, {precise5: [rocksoftware]}
@zprima
Copy link

zprima commented Apr 9, 2018

The line 13 does nothing as to_json returns, not modifies

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment