Skip to content

Instantly share code, notes, and snippets.

@pgroudas
Created January 28, 2013 22:55
Show Gist options
  • Save pgroudas/4660070 to your computer and use it in GitHub Desktop.
Save pgroudas/4660070 to your computer and use it in GitHub Desktop.
require 'net/http'
require 'json'
auth_token = '<put_the_auth_token_you_get_back_here>'
search_endpoint = 'http://localhost:5000/listing/'
login_endpoint = 'http://localhost:5000/login'
json = JSON.dump(
{
"email"=>"foo@urbancompass.com",
"password"=>"password"
}
)
#uri = URI.parse(login_endpoint)
uri = URI.parse(search_endpoint)
# Full control
http = Net::HTTP.new(uri.host, uri.port)
request = Net::HTTP::Post.new(uri.request_uri)
request.body=json
# We are going to move to an 'api-version' header shortly, as well as adding a 'response-type' get parameter
request['content-type'] = 'application/json'
request['Authentication-Token'] = auth_token
response = http.request(request)
puts response.body
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment