Я работаю с ruby и использую API под названием food2fork.com , где у меня есть два файла recipes_controller.rb
и recipes.rb
#recipes.rb
require 'httparty'
class Recipe
include HTTParty
default_options.update(verify: false)
base_uri "http://food2fork.com/api"
default_params key: ENV["FOOD2FORK_KEY"]
format :json
def self.for (para)
get("/search",query: {q:para})["recipes"]
end
end
и второй файл recipes_controller.rb
require_relative 'recipes'
puts Recipe.for("chocolate")
, но когда я запускаю файл recipes_controller.rb
в командной строке. Я получаю сообщение об ошибке
`
C:\Users\Hamza\module-3-assignment-1>ruby recipes_controller.rb
C:/RailsInstaller/Ruby2.3.3/lib/ruby/2.3.0/json/common.rb:156:in `parse':
822: unexpected token at 'FORBIDDEN' (JSON::ParserError)
from C:/RailsInstaller/Ruby2.3.3/lib/ruby/2.3.0/json/common.rb:156:in `
parse'
from C:/RailsInstaller/Ruby2.3.3/lib/ruby/gems/2.3.0/gems/httparty-
0.16.2/lib/httparty/parser.rb:125:in `json'
from C:/RailsInstaller/Ruby2.3.3/lib/ruby/gems/2.3.0/gems/httparty-
0.16.2/lib/httparty/parser.rb:145:in `parse_supported_format'
from C:/RailsInstaller/Ruby2.3.3/lib/ruby/gems/2.3.0/gems/httparty-
0.16.2/lib/httparty/parser.rb:110:in `parse'
from C:/RailsInstaller/Ruby2.3.3/lib/ruby/gems/2.3.0/gems/httparty-
0.16.2/lib/httparty/parser.rb:69:in `call'
from C:/RailsInstaller/Ruby2.3.3/lib/ruby/gems/2.3.0/gems/httparty-
0.16.2/lib/httparty/request.rb:391:in `parse_response'
from C:/RailsInstaller/Ruby2.3.3/lib/ruby/gems/2.3.0/gems/httparty-
0.16.2/lib/httparty/request.rb:359:in `block in handle_response'
from C:/RailsInstaller/Ruby2.3.3/lib/ruby/gems/2.3.0/gems/httparty-
0.16.2/lib/httparty/response.rb:25:in `parsed_response'
from C:/RailsInstaller/Ruby2.3.3/lib/ruby/gems/2.3.0/gems/httparty-
0.16.2/lib/httparty/response.rb:96:in `method_missing'
from C:/Users/Hamza/module-3-assignment-1/receipes.rb:12:in `for'
from recipes_controller.rb:4:in `<main>'