我有以下类和控制器
[HttpPost]
public ActionResult OracleVerification(string company, string location, string product, string department)
{
List<OracleStringViewModel> oracleStringList = OracleStringRepository.GetOracleStrings(company, location, product, department);
return View(oracleStringList.ToList());
}
class Recipe
include HTTParty
hostport = ENV["FOOD2FORK_SERVER_AND_PORT"] || "www.food2fork.com"
base_uri "http://#{hostport}/api"
default_params key: ENV["FOOD2FORK_KEY"]
format :json
def self.for (keyword)
request = get("/search", query: { q: keyword })
begin
request.inspect
rescue => e
puts e.inspect
end
return request.parsed_response["recipes"]
end
end
RecipesController中的JSON :: ParserError #index
答案 0 :(得分:0)
如何修复795:意外令牌在&#39; FORBIDDEN&#39;?
这意味着ENV [&#34; FOOD2FORK_KEY&#34;]中给出的密钥是错误的,您应该使用puts来检查是否为零。
答案 1 :(得分:0)
我知道这有点旧了,但是如果你正在学习这门课程,那么Wiki中的语法有些错误
`echo 'export FOOD2FORK_KEY = "Your API Key"' >> ~/.profile`
应该是
`echo 'export FOOD2FORK_KEY="Your API Key"' >> ~/.profile`
您需要编辑〜/ .profile并删除那些设置的ENV Vars