Skip to content

Instantly share code, notes, and snippets.

@PositiveControl
Created May 4, 2014 05:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save PositiveControl/a879acf7cbb4ba846866 to your computer and use it in GitHub Desktop.
Save PositiveControl/a879acf7cbb4ba846866 to your computer and use it in GitHub Desktop.
Error with PUTS to API
# ERROR OUTPUT IN TERMINAL
#Started POST "/tickets/525204671" for 127.0.0.1 at 2014-05-03 23:17:01 -0600
#Processing by WelcomeController#update as HTML
# Parameters: {"price"=>"66.77", "event"=>"4426617", "id"=>"525204671"}
#<HTTParty::Response:0x7fd0cb6d1520 parsed_response={"error"=>{"code"=>"java.io.EOFException", "description"=>"No content to map to Object due to end of input", "requestId"=>"_76a2d494-5936-431d-9889-a71ec03b3fe8"}}, @response=#<Net::HTTPInternalServerError 500 Internal Server Error readbody=true>, @headers={"content-type"=>["application/json"], "com-stubhub-dye"=>["_76a2d494-5936-431d-9889-a71ec03b3fe8"], "com-stubhub-dye-path"=>["_76a2d494-5936-431d-9889-a71ec03b3fe8"], "server"=>["Apache"], "expires"=>["Sun, 04 May 2014 05:17:01 GMT"], "cache-control"=>["max-age=0, no-cache, no-store"], "pragma"=>["no-cache"], "date"=>["Sun, 04 May 2014 05:17:01 GMT"], "connection"=>["close"]}>
#Redirected to http://localhost:3000/events/4426617
#Completed 302 Found in 231ms (ActiveRecord: 0.0ms)
# WELCOME/SHOW
<form action="/tickets/<%= ticket_group["id"] %>" method="post">
<input type="text" name="price" value="<%= "$#{ticket_group["pricePerTicket"]["amount"]}" %>"><input type="hidden" name="event" value="<%= ticket_group["eventId"] %>"><input type="submit" value="Update"></td>
# WELCOMECONTROLLER
class WelcomeController < ApplicationController
def show
@ticket_groups = StubHub.new.ticket_group_by_event(params[:id])
end
def update
StubHub.new.update_price(params[:id], params[:price])
redirect_to "/events/#{params[:event]}"
end
end
# STUBHUB MODEL
class StubHub
def update_price(id, price)
HTTParty.put("https://api.stubhub.com/inventory/listings/v1/#{id}", {:query => {:listing => {:pricePerTicket => {:amount => "#{price}", :currency => 'USD'}}}, :headers => {'Content-Type' => 'application/json', 'Authorization' => 'Bearer 11d416791974aac1769684fba7f5f9'}})
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment