0
我試圖使用我的登錄用戶的返回apikey向我的頭添加授權,但是它似乎無法工作,因爲出現apikey丟失的錯誤(是來自網絡服務的返回錯誤)如何使用Swift 3.0 + Alamofire 4.0在頭上添加授權
func getFavourites()
{
let headers = ["Content-Type": "application/x-www-form-urlencoded", "authorization" : user.apiKey ]
Alamofire.request("http://localhost:8888/food_pin/v1/restaurantToFavourites", method: HTTPMethod.get, encoding: URLEncoding.default, headers: headers).responseJSON { (response:DataResponse<Any>) in
if response.result.value != nil
{
print(response.result.value!)
print(response.response!)
self.returnAllFavourites(data: response.data!)
}
else
{
print(response.result.error!)
}
}
}
你確定它不是'Authorization'嗎? – fpg1503
這就是它是如何寫在我的web服務我把它改爲資本只是爲了看到你是對的謝謝你 – giorgos7
我已經添加它作爲答案 – fpg1503