Im using rails for with the crunchbase api to pull down the info for companies and I've been battling this error all night. It completes one request successfully and after constructing the second request it crashes and I receive this error:
Error/Users/Rich/.rvm/rubies/ruby-2.0.0-p195/lib/ruby/2.0.0/psych.rb:205:in `parse':
(<unknown>): control characters are not allowed at line 1 column 1 (Psych::SyntaxError)
I can post as much code as necessary. All help is much appreciated as I'm a ruby newbie.
def get_data(company_links)
while i < company_links.length
puts "USING URL #{URL}#{company_links[i]}.js?#{API_Key}"
resp = RestClient.get("#{URL}#{company_links[i]}.js?#{API_Key}")
arr = Crack::JSON.parse(resp)
i += 1
end
end
calling the method
links_array = ["dropbox","twitter"]
get_data(links_array)
Edit Answer Found Don't really know why it works but im not complaining that its solved. Thanks to everyone who provided assistance I really appreciate it :)
def get_data(links_array) links_array.each do |company| puts "USING URL #{URL}#{company}.js?#{API_Key}" resp = RestClient.get("#{URL}#{company}.js?#{API_Key}") arr = JSON.parse(resp) puts arr["name"] end end