ruby on rails 4 - Unknown format error when trying to respond_to format.xml -
i'm trying parse simple xml post request , send 200 status in response i'm receiving unknown format error, not understand why. action says processing / not xml. great!
actioncontroller::unknownformat (actioncontroller::unknownformat): app/controllers/locations_controller.rb:171:in `vz_api' started post "/vz_api" 127.0.0.1 @ 2014-06-25 19:52:27 -0400 processing locationscontroller#vz_api */* def vz_api require 'nokogiri' xml_doc = nokogiri::xml(request.body.read) vin = xml_doc.xpath("//vin").inner_text @truck = truck.find_by(vin: vin) @location = @truck.location lat = xml_doc.xpath("//latitude").inner_text lng = xml_doc.xpath("//longitude").inner_text heading = xml_doc.xpath("//heading").inner_text speed = xml_doc.xpath("//speed")[0].inner_text @location.update_attributes(longitude: lng, latitude: lat, speed: speed, direction: heading) respond_to |format| format.xml # format.json render :nothing => true, :status => :ok # return true end end end
rails processing / not xml or json, why don't try following instead
remove respond_to block , have:
render :nothing => true, status: :ok
Comments
Post a Comment