Sha256: 17c74da4d205e3a18cdb896e696a12fbca6ecd8f64bfde493e8a4b6d137d60a6

Contents?: true

Size: 807 Bytes

Versions: 162

Compression:

Stored size: 807 Bytes

Contents

dir = File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib'))
require File.join(dir, 'httparty')
require 'pp'

# You can also use post, put, delete, head, options in the same fashion
response = HTTParty.get('https://api.stackexchange.com/2.2/questions?site=stackoverflow')
puts response.body, response.code, response.message, response.headers.inspect

# An example post to a minimal rails app in the development environment
# Note that "skip_before_filter :verify_authenticity_token" must be set in the
# "pears" controller for this example

class Partay
  include HTTParty
  base_uri 'http://localhost:3000'
end

options = {
  body: {
    pear: { # your resource
      foo: '123', # your columns/data
      bar: 'second',
      baz: 'last thing'
    }
  }
}

pp Partay.post('/pears.xml', options)

Version data entries

162 entries across 136 versions & 10 rubygems

Version Path
harbr-0.2.0 vendor/bundle/ruby/3.2.0/gems/httparty-0.21.0/examples/basic.rb
harbr-0.1.99 vendor/bundle/ruby/3.2.0/gems/httparty-0.21.0/examples/basic.rb
harbr-0.1.98 vendor/bundle/ruby/3.2.0/gems/httparty-0.21.0/examples/basic.rb
harbr-0.1.97 vendor/bundle/ruby/3.2.0/gems/httparty-0.21.0/examples/basic.rb
harbr-0.1.96 vendor/bundle/ruby/3.2.0/gems/httparty-0.21.0/examples/basic.rb
harbr-0.1.95 vendor/bundle/ruby/3.2.0/gems/httparty-0.21.0/examples/basic.rb
harbr-0.1.94 vendor/bundle/ruby/3.2.0/gems/httparty-0.21.0/examples/basic.rb
harbr-0.1.93 vendor/bundle/ruby/3.2.0/gems/httparty-0.21.0/examples/basic.rb
harbr-0.1.91 vendor/bundle/ruby/3.2.0/gems/httparty-0.21.0/examples/basic.rb
harbr-0.1.90 vendor/bundle/ruby/3.2.0/gems/httparty-0.21.0/examples/basic.rb
harbr-0.1.89 vendor/bundle/ruby/3.2.0/gems/httparty-0.21.0/examples/basic.rb
harbr-0.1.88 vendor/bundle/ruby/3.2.0/gems/httparty-0.21.0/examples/basic.rb
harbr-0.1.87 vendor/bundle/ruby/3.2.0/gems/httparty-0.21.0/examples/basic.rb
harbr-0.1.86 vendor/bundle/ruby/3.2.0/gems/httparty-0.21.0/examples/basic.rb
harbr-0.1.85 vendor/bundle/ruby/3.2.0/gems/httparty-0.21.0/examples/basic.rb
harbr-0.1.84 vendor/bundle/ruby/3.2.0/gems/httparty-0.21.0/examples/basic.rb
harbr-0.1.83 vendor/bundle/ruby/3.2.0/gems/httparty-0.21.0/examples/basic.rb
harbr-0.1.82 vendor/bundle/ruby/3.2.0/gems/httparty-0.21.0/examples/basic.rb
harbr-0.1.81 vendor/bundle/ruby/3.2.0/gems/httparty-0.21.0/examples/basic.rb
harbr-0.1.80 vendor/bundle/ruby/3.2.0/gems/httparty-0.21.0/examples/basic.rb