Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
HTTParty Examples
options = { :body =>
{ :username => 'my',
:password => 'password'
}
}
results = HTTParty.post("http://api.topcoder.com/v2/auth", options)
##
## example for post with papertrail and basic auth
##
auth = {
:username => ENV['PAPERTRAIL_DIST_USERNAME'],
:password => ENV['PAPERTRAIL_DIST_PASSWORD']
}
# create the user's account
user = {
:id => membername,
:email => email
}
payload = {
:id => membername,
:name => membername,
:user => user,
:plan => 'free'
}
options = {
:body => payload,
:basic_auth => auth
}
results = HTTParty.post("https://papertrailapp.com/api/v1/distributors/accounts", options)
results = HTTParty.get("http://some.api", :headers => {
"X-Api-Key" => "#{api_key}",
"Content-Type" => "application/json",
"Authorization" => "Bearer #{response.access_token}"
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.