Skip to content

Instantly share code, notes, and snippets.

@HADDADSOHAIB
Forked from jeffdonthemic/httparty.rb
Created March 1, 2021 15:26
Show Gist options
  • Select an option

  • Save HADDADSOHAIB/a2bb5480c8d4f95e2a6ff40379325741 to your computer and use it in GitHub Desktop.

Select an option

Save HADDADSOHAIB/a2bb5480c8d4f95e2a6ff40379325741 to your computer and use it in GitHub Desktop.

Revisions

  1. @jeffdonthemic jeffdonthemic revised this gist Jul 15, 2016. 1 changed file with 6 additions and 0 deletions.
    6 changes: 6 additions & 0 deletions httparty.rb
    Original file line number Diff line number Diff line change
    @@ -31,3 +31,9 @@
    }

    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}"
    })
  2. @jeffdonthemic jeffdonthemic revised this gist Aug 1, 2014. 1 changed file with 33 additions and 1 deletion.
    34 changes: 33 additions & 1 deletion httparty.rb
    Original file line number Diff line number Diff line change
    @@ -1 +1,33 @@
    d
    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)
  3. @jeffdonthemic jeffdonthemic created this gist Aug 1, 2014.
    1 change: 1 addition & 0 deletions httparty.rb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1 @@
    d