我一直在与Alamofire迅速合作,以获得Spoonacular Api的请求。
我一直在给我错误:“code = 0; link =“https://www.mashape.com/webknox/”; message =“我们很抱歉,出了点问题。如果此错误仍然存在,请与我们联系。”; status = 405;“
我一直在搜索并尝试了很多东西,但似乎没有任何东西可以返回我需要继续的JSON。
func APITest(){
let retrievedString: String? = KeychainWrapper.standard.string(forKey: "SpoonacularApi")
let parameters: Parameters = [
"ingredients":"apples2Cflour%2Csugar&",
]
let headers: HTTPHeaders = [
"other":"limitLicense=false&number=5&ranking=",
"X-Mashape-Key": retrievedString!,
"X-Mashape-Host": "spoonacular-recipe-food-nutrition-v1.p.mashape.com",
"accept": "application/json",
]
Alamofire.request("https://spoonacular-recipe-food-nutrition-v1.p.mashape.com/recipes/findByIngredients?fillIngredients=false&ingredients=",
method: .post, parameters: parameters,encoding: JSONEncoding.default, headers: headers).responseJSON { response in
debugPrint(response)
switch response.result{
case .success(let value):
let json = JSON(value)
print (json)
case .failure(let error):
print(error)
}
}
}