Search code examples
ruby-on-railsruby-on-rails-3jsonactiveresourceactivesupport

MultiJson::DecodeError: 399: unexpected token at


This is my code

class Project < ActiveResource::Base
  self.site = "https://xyz.unfuddle.com/api/v1"
  def get_tickets
    ticket_array = []
    Project.all.each do |project|
      project.get(:tickets).each do |ticket|
        #save ticket or something
      end
    end
  end   
end  

The error occurs in project.get(:tickets)

lexical error: invalid character inside string.
 16           ": "There is text that shouldn^Zt be there on the DVD/Blu-ray
 17                      (right here) ------^

How can I check before get if the returned text has only valid characters ?


Solution

  • you need to get the data anyways. otherwise you won't be able to check it for validity. that's why i would just add a try-catch-block and rescue the specific error.